keep-github-workflows-active 2.3.3__tar.gz → 2.3.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.gitignore +8 -4
  2. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/CHANGELOG.md +8 -0
  3. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/Makefile +38 -4
  4. keep_github_workflows_active-2.3.4/OPEN-WORK.md +5 -0
  5. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/PKG-INFO +11 -11
  6. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/docs/systemdesign/module_reference.md +5 -13
  7. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/pyproject.toml +9 -9
  8. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/src/keep_github_workflows_active/__init__conf__.py +1 -1
  9. keep_github_workflows_active-2.3.4/src/keep_github_workflows_active/__main__.py +13 -0
  10. keep_github_workflows_active-2.3.4/tests/test_module_entry.py +79 -0
  11. keep_github_workflows_active-2.3.3/src/keep_github_workflows_active/__main__.py +0 -117
  12. keep_github_workflows_active-2.3.3/tests/test_module_entry.py +0 -166
  13. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.devcontainer/devcontainer.json +0 -0
  14. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.devcontainer/settings.json +0 -0
  15. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.env.example +0 -0
  16. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.gitattributes +0 -0
  17. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.github/actions/extract-metadata/action.yml +0 -0
  18. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.github/dependabot.yml +0 -0
  19. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.github/workflows/activate_workflows.yml +0 -0
  20. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.github/workflows/activate_workflows_priv.yml +0 -0
  21. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.github/workflows/codeql.yml +0 -0
  22. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.github/workflows/default_cicd_public.yml +0 -0
  23. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.github/workflows/default_release_public.yml +0 -0
  24. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.qlty/qlty.toml +0 -0
  25. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/.snyk +0 -0
  26. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/CONTRIBUTING.md +0 -0
  27. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/DEVELOPMENT.md +0 -0
  28. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/INSTALL.md +0 -0
  29. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/LICENSE +0 -0
  30. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/README.md +0 -0
  31. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/codecov.yml +0 -0
  32. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/concept.md +0 -0
  33. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/docs/systemdesign/SECURITY.md +0 -0
  34. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/notebooks/Quickstart.ipynb +0 -0
  35. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/src/keep_github_workflows_active/__init__.py +0 -0
  36. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/src/keep_github_workflows_active/behaviors.py +0 -0
  37. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/src/keep_github_workflows_active/cli.py +0 -0
  38. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/src/keep_github_workflows_active/doctest.env +0 -0
  39. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/src/keep_github_workflows_active/keep_github_workflow_active.py +0 -0
  40. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/src/keep_github_workflows_active/py.typed +0 -0
  41. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/src/keep_github_workflows_active/sanitization.py +0 -0
  42. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/src/keep_github_workflows_active/typed_click.py +0 -0
  43. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/tests/conftest.py +0 -0
  44. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/tests/test_behaviors.py +0 -0
  45. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/tests/test_cli.py +0 -0
  46. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/tests/test_github_integration.py +0 -0
  47. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/tests/test_metadata.py +0 -0
  48. {keep_github_workflows_active-2.3.3 → keep_github_workflows_active-2.3.4}/tests/test_sanitization.py +0 -0
@@ -46,7 +46,8 @@ tmp_*
46
46
  # *.py[cod]: catches .pyc, .pyo, .pyd
47
47
  __pycache__/
48
48
  *.py[cod]
49
- *$py.class # other compiled artifacts
49
+ # other compiled artifacts
50
+ *$py.class
50
51
 
51
52
  # pytest, coverage, MyPy, Hypothesis
52
53
  .pytest_cache/
@@ -72,12 +73,15 @@ coverage.xml
72
73
  # source/package builds
73
74
  build/
74
75
  dist/
75
- *.egg-info/ # metadata for pip installs
76
+ # metadata for pip installs
77
+ *.egg-info/
76
78
  *.egg
77
79
  *.whl
78
80
  pip-wheel-metadata/
79
- *.manifest # PyInstaller metadata
80
- *.spec # PyInstaller spec files
81
+ # PyInstaller metadata
82
+ *.manifest
83
+ # PyInstaller spec files
84
+ *.spec
81
85
 
82
86
  # Eggs, parts, wheels, sdist, etc.
83
87
  develop-eggs/
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [2.3.4] 2026-10-05 19:35:58
6
+
7
+ ### Fixed
8
+ - `python -m keep_github_workflows_active` now runs `cli.main()` like the console scripts; a usage error (bad flag, unknown command) exits 2 instead of 1.
9
+
10
+ ### Changed
11
+ - Raised dependency and dev tool floors to their current releases.
12
+
5
13
  ## [2.3.3] 2026-07-24
6
14
 
7
15
  ### Changed
@@ -1,4 +1,4 @@
1
- # BMK MAKEFILE 3.13.0
1
+ # BMK MAKEFILE 3.18.0
2
2
  # do not alter this file - it might be overwritten on new versions of BMK
3
3
  # if You want to alter it, remove the first line # BMK MAKEFILE 1.0 - then it is a custom makefile and will not be overwritten
4
4
  # bmk Makefile - thin wrapper using `uv tool upgrade` for persistent bmk
@@ -186,16 +186,50 @@ endif
186
186
  # BMK_MIN floors the FALLBACK install. The upgrade path does not consult it: uv re-resolves
187
187
  # the requirement recorded at install time, which is itself a `bmk>=...`, so it always lands
188
188
  # on the newest release and clears the floor anyway.
189
- BMK_MIN := 3.13.0
189
+ BMK_MIN := 3.18.0
190
190
 
191
191
  # Absent env, missing check, or damaged env - all three mean "do not upgrade, rebuild".
192
192
  # `test -x` keeps a fresh machine quiet: there is no interpreter to run yet.
193
193
  BMK_INTACT := $(if $(BMK_PY),test -x "$(BMK_PY)" && "$(BMK_PY)" -m bmk_selfcheck,false)
194
194
 
195
+ # The env this recipe mutates is shared by EVERY repo on the machine, so the mutation has to
196
+ # wait for the bmk processes running out of it. Every bmk started from that env holds a
197
+ # SHARED lock on <uv tool dir>/.bmk-tool.lock for its whole lifetime; these wrappers take
198
+ # the same lock EXCLUSIVE for the length of the upgrade. Without it, a make here deleted the
199
+ # site-packages out from under a bmk minutes into a test suite in an UNRELATED repo, and it
200
+ # surfaced as an ImportError inside bmk's OWN dependencies that cleared on a re-run - so it
201
+ # read as a flake rather than as the environment vanishing mid-gate.
202
+ #
203
+ # `bmk_toollock` is a second stdlib-only TOP-LEVEL module bmk ships, run on the tool env's
204
+ # own interpreter. That is not circular: a uv tool env's bin/python is a SYMLINK to a base
205
+ # interpreter OUTSIDE the tool dir, so the stdlib the guard runs on is not part of the tree
206
+ # uv is about to replace, and the guard is read and compiled before uv is ever spawned.
207
+ #
208
+ # NOT uv's own <uv tool dir>/.lock, which uv does honour: `uv tool upgrade` and `uv tool
209
+ # list` block on it too (measured), and the upgrade runs before every target - so a
210
+ # gate-lifetime shared lock there would make every make on the machine, and every unrelated
211
+ # `uv tool install`, wait for the longest-running gate.
212
+ #
213
+ # $(wildcard) rather than a shell test: on a machine with no tool env yet these expand to
214
+ # NOTHING and the install runs bare, which is exactly what a first install needs.
215
+ #
216
+ # The bounded wait is load-bearing in both directions. An unbounded one would serialise
217
+ # every repo's make behind the longest gate on the machine. A SKIPPED upgrade costs nothing
218
+ # (the next make picks it up), so the upgrade skips. The REPAIR may not skip: proceeding
219
+ # would leave a damaged env in place, so it fails and drops through to the retry.
220
+ #
221
+ # The LAST attempt is deliberately NEVER guarded, and a test pins that. The guard lives
222
+ # inside the env being repaired, so on the path where that env is absent or broken the guard
223
+ # may be broken too; an unguarded last resort is what stops a defective guard from making
224
+ # `make` unrunnable in every repo at once. If bmk_toollock ever falls out of the wheel, every
225
+ # make everywhere drops to a full reinstall - there is a packaging test for exactly that.
226
+ BMK_LOCK := $(if $(wildcard $(BMK_PY)),"$(BMK_PY)" -m bmk_toollock --exclusive --timeout 10 --on-timeout skip --,)
227
+ BMK_LOCK_REPAIR := $(if $(wildcard $(BMK_PY)),"$(BMK_PY)" -m bmk_toollock --exclusive --timeout 60 --on-timeout fail --,)
228
+
195
229
  .PHONY: _ensure_bmk
196
230
  _ensure_bmk:
197
- @$(BMK_INTACT) && uv tool upgrade bmk \
198
- || uv tool install --reinstall --force "bmk>=$(BMK_MIN)" \
231
+ @$(BMK_INTACT) && $(BMK_LOCK) uv tool upgrade bmk \
232
+ || $(BMK_LOCK_REPAIR) uv tool install --reinstall --force "bmk>=$(BMK_MIN)" \
199
233
  || uv tool install --reinstall --force "bmk>=$(BMK_MIN)"
200
234
 
201
235
  # ──────────────────────────────────────────────────────────────
@@ -0,0 +1,5 @@
1
+ # Open work
2
+
3
+ Standing backlog. Edit line by line, never rewrite wholesale. When an item is finished, delete
4
+ its line; the reason it closed belongs in the commit message, CHANGELOG or git history.
5
+
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: keep_github_workflows_active
3
- Version: 2.3.3
3
+ Version: 2.3.4
4
4
  Summary: Template for python apps with registered cli commands
5
5
  Project-URL: Homepage, https://github.com/bitranox/keep_github_workflows_active
6
6
  Project-URL: Repository, https://github.com/bitranox/keep_github_workflows_active.git
@@ -17,23 +17,23 @@ Classifier: Programming Language :: Python :: 3 :: Only
17
17
  Classifier: Programming Language :: Python :: 3.14
18
18
  Classifier: Typing :: Typed
19
19
  Requires-Python: >=3.10
20
- Requires-Dist: lib-cli-exit-tools>=2.3.3
21
- Requires-Dist: pydantic>=2.13.4
20
+ Requires-Dist: lib-cli-exit-tools>=2.3.4
21
+ Requires-Dist: pydantic>=2.13.5
22
22
  Requires-Dist: requests>=2.34.2
23
- Requires-Dist: rich-click>=1.9.8
23
+ Requires-Dist: rich-click>=1.9.9
24
24
  Provides-Extra: dev
25
25
  Requires-Dist: bandit>=1.9.4; extra == 'dev'
26
- Requires-Dist: build>=1.5.0; extra == 'dev'
27
- Requires-Dist: click>=8.4.2; extra == 'dev'
28
- Requires-Dist: import-linter>=2.13; extra == 'dev'
26
+ Requires-Dist: build>=1.6.1; extra == 'dev'
27
+ Requires-Dist: click>=8.5.0; extra == 'dev'
28
+ Requires-Dist: import-linter>=2.15; extra == 'dev'
29
29
  Requires-Dist: pip-audit>=2.10.1; extra == 'dev'
30
- Requires-Dist: pyright[nodejs]>=1.1.411; extra == 'dev'
30
+ Requires-Dist: pyright[nodejs]>=1.1.414; extra == 'dev'
31
31
  Requires-Dist: pytest-cov>=7.1.0; extra == 'dev'
32
32
  Requires-Dist: pytest>=9.1.1; extra == 'dev'
33
33
  Requires-Dist: rtoml>=0.13.0; extra == 'dev'
34
- Requires-Dist: ruff>=0.16.0; extra == 'dev'
34
+ Requires-Dist: ruff>=0.16.10; extra == 'dev'
35
35
  Requires-Dist: textual>=8.2.8; extra == 'dev'
36
- Requires-Dist: twine>=6.2.0; extra == 'dev'
36
+ Requires-Dist: twine>=7.0.0; extra == 'dev'
37
37
  Description-Content-Type: text/markdown
38
38
 
39
39
  # keep_github_workflows_active
@@ -125,20 +125,12 @@ stand-in domain.
125
125
  or the exit code produced by ``lib_cli_exit_tools``.
126
126
  * **Location:** src/keep_github_workflows_active/cli.py
127
127
 
128
- ### __main__._module_main
128
+ ### __main__
129
129
 
130
- * **Purpose:** Provide ``python -m`` entry point mirroring the console script.
131
- * **Input:** None.
132
- * **Output:** Exit code from ``cli.main`` after restoring traceback state.
133
- * **Location:** src/keep_github_workflows_active/__main__.py
134
-
135
- ### __main__._open_cli_session / _command_to_run / _command_name
136
-
137
- * **Purpose:** Describe the session wiring and command selection used by the
138
- module entry point so tests and documentation can reason about the
139
- composition.
140
- * **Output:** Context manager yielding the command runner, the Click command
141
- itself, and the shell-facing name.
130
+ * **Purpose:** Provide the ``python -m`` entry point; runs ``cli.main`` exactly
131
+ as the console scripts do.
132
+ * **Input:** None (argv comes from ``sys.argv``).
133
+ * **Output:** ``SystemExit`` carrying the exit code returned by ``cli.main``.
142
134
  * **Location:** src/keep_github_workflows_active/__main__.py
143
135
 
144
136
  ### __init__conf__.print_info
@@ -1,10 +1,10 @@
1
1
  [project]
2
2
  name = "keep_github_workflows_active"
3
- version = "2.3.3"
3
+ version = "2.3.4"
4
4
  description = "Template for python apps with registered cli commands"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
7
- dependencies = ["rich-click>=1.9.8", "lib_cli_exit_tools>=2.3.3", "requests>=2.34.2", "pydantic>=2.13.4"]
7
+ dependencies = ["rich-click>=1.9.9", "lib_cli_exit_tools>=2.3.4", "requests>=2.34.2", "pydantic>=2.13.5"]
8
8
  license = { text = "MIT" }
9
9
  authors = [{ name = "bitranox", email = "bitranox@gmail.com" }]
10
10
  keywords = ["logging", "rich", "cli", "terminal", "ansi"]
@@ -37,13 +37,13 @@ Issues = "https://github.com/bitranox/keep_github_workflows_active/issues"
37
37
  dev = [
38
38
  "pytest>=9.1.1",
39
39
  "pytest-cov>=7.1.0",
40
- "ruff>=0.16.0",
41
- "pyright[nodejs]>=1.1.411",
40
+ "ruff>=0.16.10",
41
+ "pyright[nodejs]>=1.1.414",
42
42
  "bandit>=1.9.4",
43
43
  # 1.5.1 was yanked upstream (unintended breaking changes), so 1.5.0 is the newest usable
44
44
  # release; a >=1.5.1 floor has ZERO candidates and makes this extra unresolvable.
45
- "build>=1.5.0",
46
- "twine>=6.2.0",
45
+ "build>=1.6.1",
46
+ "twine>=7.0.0",
47
47
  # codecov-cli is disabled, not dropped: it requires click<8.3.0, which drags click back to
48
48
  # 8.2.1 - the version with CVE-2026-7246 (command injection in click.edit(), fixed in 8.3.3).
49
49
  # Nothing else here caps click, so with this line active the audit gate goes red on every
@@ -52,10 +52,10 @@ dev = [
52
52
  # Re-enable once codecov-cli relaxes its click<8.3.0 pin.
53
53
  # "codecov-cli>=11.2.8",
54
54
  # Transitive CVE pins
55
- "click>=8.4.2", # CVE-2026-7246
55
+ "click>=8.5.0", # CVE-2026-7246
56
56
  "pip-audit>=2.10.1",
57
57
  "textual>=8.2.8",
58
- "import-linter>=2.13",
58
+ "import-linter>=2.15",
59
59
  "rtoml>=0.13.0"
60
60
  ]
61
61
 
@@ -64,7 +64,7 @@ keep_github_workflows_active = "keep_github_workflows_active.cli:main"
64
64
  keep-github-workflows-active = "keep_github_workflows_active.cli:main"
65
65
 
66
66
  [build-system]
67
- requires = ["hatchling>=1.31.0"]
67
+ requires = ["hatchling>=1.32.4"]
68
68
  build-backend = "hatchling.build"
69
69
 
70
70
 
@@ -26,7 +26,7 @@ name = "keep_github_workflows_active"
26
26
  #: Human-readable summary shown in CLI help output.
27
27
  title = "Template for python apps with registered cli commands"
28
28
  #: Current release version pulled from ``pyproject.toml`` by automation.
29
- version = "2.3.3"
29
+ version = "2.3.4"
30
30
  #: Repository homepage presented to users.
31
31
  homepage = "https://github.com/bitranox/keep_github_workflows_active"
32
32
  #: Author attribution surfaced in CLI output.
@@ -0,0 +1,13 @@
1
+ """Provide the ``python -m keep_github_workflows_active`` entry point.
2
+
3
+ Runs :func:`keep_github_workflows_active.cli.main`, the function the console
4
+ scripts run, so exit codes and traceback handling are identical however the
5
+ CLI is started.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from . import cli
11
+
12
+ if __name__ == "__main__":
13
+ raise SystemExit(cli.main())
@@ -0,0 +1,79 @@
1
+ """Module entry stories ensuring `python -m` mirrors the CLI."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ import runpy
7
+ import sys
8
+ from typing import TYPE_CHECKING
9
+
10
+ import lib_cli_exit_tools
11
+ import pytest
12
+
13
+ from keep_github_workflows_active import cli as cli_mod
14
+
15
+ if TYPE_CHECKING:
16
+ from collections.abc import Callable
17
+
18
+
19
+ @pytest.mark.os_agnostic
20
+ @pytest.mark.parametrize(
21
+ "argv",
22
+ [["--bad-flag"], ["no-such-command"], ["info", "--bad-flag"], ["--help"], ["info"]],
23
+ ids=["bad-flag", "unknown-command", "bad-subcommand-flag", "help", "info"],
24
+ )
25
+ def test_module_entry_exits_with_the_code_the_console_script_gives(monkeypatch: pytest.MonkeyPatch, isolated_traceback_config: None, argv: list[str]) -> None:
26
+ script_code = cli_mod.main(argv)
27
+ monkeypatch.setattr(sys, "argv", ["keep_github_workflows_active", *argv])
28
+
29
+ with pytest.raises(SystemExit) as exc:
30
+ runpy.run_module("keep_github_workflows_active.__main__", run_name="__main__")
31
+
32
+ assert exc.value.code == script_code
33
+
34
+
35
+ @pytest.mark.os_agnostic
36
+ def test_a_usage_error_exits_with_the_click_usage_code_via_module_entry(monkeypatch: pytest.MonkeyPatch, isolated_traceback_config: None) -> None:
37
+ monkeypatch.setattr(sys, "argv", ["keep_github_workflows_active", "--bad-flag"])
38
+
39
+ with pytest.raises(SystemExit) as exc:
40
+ runpy.run_module("keep_github_workflows_active.__main__", run_name="__main__")
41
+
42
+ assert exc.value.code == 2
43
+
44
+
45
+ @pytest.mark.os_agnostic
46
+ def test_when_traceback_flag_is_used_via_module_entry_the_full_poem_is_printed(
47
+ monkeypatch: pytest.MonkeyPatch,
48
+ capsys: pytest.CaptureFixture[str],
49
+ strip_ansi: Callable[[str], str],
50
+ ) -> None:
51
+ monkeypatch.setattr(sys, "argv", ["keep_github_workflows_active", "--traceback", "fail"])
52
+ monkeypatch.setattr(lib_cli_exit_tools.config, "traceback", False, raising=False)
53
+ monkeypatch.setattr(lib_cli_exit_tools.config, "traceback_force_color", False, raising=False)
54
+
55
+ with pytest.raises(SystemExit) as exc:
56
+ runpy.run_module("keep_github_workflows_active.__main__", run_name="__main__")
57
+
58
+ plain_err = strip_ansi(capsys.readouterr().err)
59
+
60
+ assert exc.value.code != 0
61
+ assert "Traceback (most recent call last)" in plain_err
62
+ assert "RuntimeError: I should fail" in plain_err
63
+ assert "[TRUNCATED" not in plain_err
64
+ assert lib_cli_exit_tools.config.traceback is False
65
+ assert lib_cli_exit_tools.config.traceback_force_color is False
66
+
67
+
68
+ @pytest.mark.os_agnostic
69
+ def test_when_the_module_is_imported_it_runs_nothing() -> None:
70
+ # Left imported, every later runpy of the module warns that it is already loaded.
71
+ previous = sys.modules.pop("keep_github_workflows_active.__main__", None)
72
+ try:
73
+ module = importlib.import_module("keep_github_workflows_active.__main__")
74
+
75
+ assert module.cli is cli_mod
76
+ finally:
77
+ sys.modules.pop("keep_github_workflows_active.__main__", None)
78
+ if previous is not None:
79
+ sys.modules["keep_github_workflows_active.__main__"] = previous
@@ -1,117 +0,0 @@
1
- """Module entry point ensuring SystemExit semantics match project standards.
2
-
3
- Purpose
4
- -------
5
- Provide the ``python -m keep_github_workflows_active`` path mandated by the
6
- project's packaging guidelines. The wrapper delegates to
7
- :func:`keep_github_workflows_active.cli.main` so that module execution mirrors the
8
- installed console script, including traceback handling and exit-code mapping.
9
-
10
- Contents
11
- --------
12
- * :func:`_open_cli_session` - wires ``cli_session`` with the agreed limits.
13
- * :func:`_command_to_run` / :func:`_command_name` - expose the command and label
14
- used by the module entry.
15
- * :func:`_module_main` - drives execution and returns the exit code.
16
-
17
- System Role
18
- -----------
19
- Lives in the adapters layer. It bridges CPython's module execution entry point
20
- to the shared CLI helper while reusing the same ``cli_session`` orchestration
21
- documented in ``docs/systemdesign/module_reference.md``.
22
- """
23
-
24
- from __future__ import annotations
25
-
26
- from collections.abc import Callable
27
- from typing import TYPE_CHECKING, Final
28
-
29
- from lib_cli_exit_tools import cli_session
30
-
31
- from . import __init__conf__, cli
32
-
33
- if TYPE_CHECKING:
34
- from contextlib import AbstractContextManager
35
-
36
- import rich_click as click
37
-
38
- # Match the CLI defaults so truncation behaviour stays consistent across entry
39
- # points regardless of whether users call the console script or ``python -m``.
40
- #: Character budget for truncated tracebacks when running via module entry.
41
- TRACEBACK_SUMMARY_LIMIT: Final[int] = cli.TRACEBACK_SUMMARY_LIMIT
42
- #: Character budget for verbose tracebacks when running via module entry.
43
- TRACEBACK_VERBOSE_LIMIT: Final[int] = cli.TRACEBACK_VERBOSE_LIMIT
44
-
45
-
46
- CommandRunner = Callable[..., int]
47
-
48
-
49
- def _open_cli_session() -> AbstractContextManager[CommandRunner]:
50
- """Return the configured ``cli_session`` context manager.
51
-
52
- Why
53
- ``cli_session`` wires ``lib_cli_exit_tools`` with the tracing limits we
54
- want for module execution. Wrapping it keeps the configuration in a
55
- single place.
56
-
57
- Outputs
58
- AbstractContextManager[CommandRunner]:
59
- Context manager that yields the callable responsible for invoking
60
- the Click command.
61
- """
62
-
63
- return cli_session(
64
- summary_limit=TRACEBACK_SUMMARY_LIMIT,
65
- verbose_limit=TRACEBACK_VERBOSE_LIMIT,
66
- )
67
-
68
-
69
- def _command_to_run() -> click.Command:
70
- """Expose the click command that powers the module entry.
71
-
72
- Why
73
- Keeps the module entry explicit about which command is being executed
74
- while remaining easy to stub in tests.
75
-
76
- Outputs
77
- click.Command: reference to the root CLI command group.
78
- """
79
-
80
- return cli.cli
81
-
82
-
83
- def _command_name() -> str:
84
- """Return the shell-friendly name announced by the session.
85
-
86
- Why
87
- ``lib_cli_exit_tools`` uses this value when presenting help and error
88
- messages; we centralise the derivation so tests can assert against it.
89
-
90
- Outputs
91
- str: Name of the console script as published through entry points.
92
- """
93
-
94
- return __init__conf__.shell_command
95
-
96
-
97
- def _module_main() -> int:
98
- """Execute the CLI entry point and return a normalised exit code.
99
-
100
- Why
101
- Implements ``python -m keep_github_workflows_active`` by delegating to the
102
- shared CLI composition while respecting the configured traceback
103
- budgets.
104
-
105
- Outputs
106
- int: Exit code reported by the CLI run.
107
- """
108
-
109
- with _open_cli_session() as run:
110
- return run(
111
- _command_to_run(),
112
- prog_name=_command_name(),
113
- )
114
-
115
-
116
- if __name__ == "__main__":
117
- raise SystemExit(_module_main())
@@ -1,166 +0,0 @@
1
- """Module entry stories ensuring `python -m` mirrors the CLI."""
2
-
3
- from __future__ import annotations
4
-
5
- import runpy
6
- import sys
7
- from dataclasses import dataclass
8
- from typing import TYPE_CHECKING, TextIO
9
-
10
- import lib_cli_exit_tools
11
- import pytest
12
-
13
- from keep_github_workflows_active import __init__conf__
14
- from keep_github_workflows_active import cli as cli_mod
15
-
16
- if TYPE_CHECKING:
17
- from collections.abc import Callable
18
-
19
-
20
- @dataclass(slots=True)
21
- class PrintedTraceback:
22
- """Capture of a traceback rendering invoked by ``lib_cli_exit_tools``.
23
-
24
- Attributes
25
- ----------
26
- trace_back:
27
- ``True`` when verbose tracebacks were printed.
28
- length_limit:
29
- Character budget applied to the output.
30
- stream_present:
31
- ``True`` when a stream object was provided to the printer.
32
- """
33
-
34
- trace_back: bool
35
- length_limit: int
36
- stream_present: bool
37
-
38
-
39
- def _record_print_message(target: list[PrintedTraceback]) -> Callable[..., None]:
40
- """Return an exception printer that records each invocation.
41
-
42
- Why
43
- Module-entry tests assert that ``lib_cli_exit_tools`` prints the correct
44
- style of traceback; capturing the parameters lets the test assert intent
45
- without examining stderr.
46
-
47
- Inputs
48
- target:
49
- Mutable list collecting :class:`PrintedTraceback` entries.
50
-
51
- Outputs
52
- Callable[..., None]:
53
- Replacement printer used during the test.
54
- """
55
-
56
- def _printer(
57
- *,
58
- trace_back: bool = False,
59
- length_limit: int = 500,
60
- stream: TextIO | None = None,
61
- ) -> None:
62
- target.append(
63
- PrintedTraceback(
64
- trace_back=trace_back,
65
- length_limit=length_limit,
66
- stream_present=stream is not None,
67
- )
68
- )
69
-
70
- return _printer
71
-
72
-
73
- @pytest.mark.os_agnostic
74
- def test_when_module_entry_returns_zero_the_story_matches_cli(monkeypatch: pytest.MonkeyPatch) -> None:
75
- ledger: dict[str, object] = {}
76
-
77
- monkeypatch.setattr(sys, "argv", ["keep_github_workflows_active"], raising=False)
78
-
79
- def fake_run_cli(
80
- command: object,
81
- argv: list[str] | None = None,
82
- *,
83
- prog_name: str | None = None,
84
- **_: object,
85
- ) -> int:
86
- ledger["command"] = command
87
- ledger["argv"] = argv
88
- ledger["prog_name"] = prog_name
89
- return 0
90
-
91
- monkeypatch.setattr(lib_cli_exit_tools, "run_cli", fake_run_cli)
92
- monkeypatch.setattr("lib_cli_exit_tools.application.runner.run_cli", fake_run_cli)
93
-
94
- with pytest.raises(SystemExit) as exc:
95
- runpy.run_module("keep_github_workflows_active.__main__", run_name="__main__")
96
-
97
- assert exc.value.code == 0
98
- assert ledger["command"] is cli_mod.cli
99
- assert ledger["prog_name"] == __init__conf__.shell_command
100
-
101
-
102
- @pytest.mark.os_agnostic
103
- def test_when_module_entry_raises_the_exit_helpers_format_the_song(monkeypatch: pytest.MonkeyPatch) -> None:
104
- printed: list[PrintedTraceback] = []
105
- codes: list[str] = []
106
- monkeypatch.setattr(sys, "argv", ["keep_github_workflows_active"], raising=False)
107
- monkeypatch.setattr(lib_cli_exit_tools.config, "traceback", False, raising=False)
108
- monkeypatch.setattr(lib_cli_exit_tools.config, "traceback_force_color", False, raising=False)
109
-
110
- def fake_code(exc: BaseException) -> int:
111
- codes.append(f"code:{exc}")
112
- return 88
113
-
114
- def exploding_run_cli(
115
- *_args: object,
116
- exception_handler: Callable[[BaseException], int] | None = None,
117
- **_kwargs: object,
118
- ) -> int:
119
- def default_handler(exc: BaseException) -> int:
120
- return 1
121
-
122
- handler: Callable[[BaseException], int] = exception_handler or default_handler
123
- return handler(RuntimeError("boom"))
124
-
125
- printer = _record_print_message(printed)
126
- monkeypatch.setattr(lib_cli_exit_tools, "print_exception_message", printer)
127
- monkeypatch.setattr(lib_cli_exit_tools, "get_system_exit_code", fake_code)
128
- monkeypatch.setattr("lib_cli_exit_tools.application.runner.print_exception_message", printer)
129
- monkeypatch.setattr("lib_cli_exit_tools.application.runner.get_system_exit_code", fake_code)
130
- monkeypatch.setattr(lib_cli_exit_tools, "run_cli", exploding_run_cli)
131
- monkeypatch.setattr("lib_cli_exit_tools.application.runner.run_cli", exploding_run_cli)
132
-
133
- with pytest.raises(SystemExit) as exc:
134
- runpy.run_module("keep_github_workflows_active.__main__", run_name="__main__")
135
-
136
- assert exc.value.code == 88
137
- assert printed == [PrintedTraceback(trace_back=False, length_limit=500, stream_present=False)]
138
- assert codes == ["code:boom"]
139
-
140
-
141
- @pytest.mark.os_agnostic
142
- def test_when_traceback_flag_is_used_via_module_entry_the_full_poem_is_printed(
143
- monkeypatch: pytest.MonkeyPatch,
144
- capsys: pytest.CaptureFixture[str],
145
- strip_ansi: Callable[[str], str],
146
- ) -> None:
147
- monkeypatch.setattr(sys, "argv", ["keep_github_workflows_active", "--traceback", "fail"])
148
- monkeypatch.setattr(lib_cli_exit_tools.config, "traceback", False, raising=False)
149
- monkeypatch.setattr(lib_cli_exit_tools.config, "traceback_force_color", False, raising=False)
150
-
151
- with pytest.raises(SystemExit) as exc:
152
- runpy.run_module("keep_github_workflows_active.__main__", run_name="__main__")
153
-
154
- plain_err = strip_ansi(capsys.readouterr().err)
155
-
156
- assert exc.value.code != 0
157
- assert "Traceback (most recent call last)" in plain_err
158
- assert "RuntimeError: I should fail" in plain_err
159
- assert "[TRUNCATED" not in plain_err
160
- assert lib_cli_exit_tools.config.traceback is False
161
- assert lib_cli_exit_tools.config.traceback_force_color is False
162
-
163
-
164
- @pytest.mark.os_agnostic
165
- def test_when_module_entry_imports_cli_the_alias_stays_intact() -> None:
166
- assert cli_mod.cli.name == cli_mod.cli.name