somnus-debug 0.1.0__py3-none-any.whl
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.
- somnus_debug/__init__.py +27 -0
- somnus_debug/cli.py +96 -0
- somnus_debug/doctor/__init__.py +13 -0
- somnus_debug/doctor/core.py +2171 -0
- somnus_debug/doctor/default_config.yaml +64 -0
- somnus_debug/pycache_cleaner/__init__.py +11 -0
- somnus_debug/pycache_cleaner/core.py +344 -0
- somnus_debug/structure/__init__.py +11 -0
- somnus_debug/structure/core.py +319 -0
- somnus_debug/test_harness/__init__.py +0 -0
- somnus_debug/test_harness/scaffold.py +97 -0
- somnus_debug/test_harness/templates/CONTRACT.md +117 -0
- somnus_debug/test_harness/templates/__init__.py +0 -0
- somnus_debug/test_harness/templates/run_test.py +827 -0
- somnus_debug-0.1.0.dist-info/METADATA +404 -0
- somnus_debug-0.1.0.dist-info/RECORD +19 -0
- somnus_debug-0.1.0.dist-info/WHEEL +4 -0
- somnus_debug-0.1.0.dist-info/entry_points.txt +5 -0
- somnus_debug-0.1.0.dist-info/licenses/LICENSE +21 -0
somnus_debug/__init__.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"""somnus_debug: Somnus Sovereign Systems' Python developer toolkit.
|
|
2
|
+
|
|
3
|
+
A pip-installable toolbox of project-agnostic diagnostic and maintenance
|
|
4
|
+
tools originally maintained as loose scripts. Each tool keeps its original
|
|
5
|
+
single-file implementation (moved, not rewritten) under its own submodule;
|
|
6
|
+
this package only adds the installable surface and a unified CLI on top.
|
|
7
|
+
|
|
8
|
+
Tools currently in the toolkit:
|
|
9
|
+
doctor -- python_production_doctor: AST-based production
|
|
10
|
+
readiness diagnostics (stubs, placeholders,
|
|
11
|
+
silent failures, dependency cycles,
|
|
12
|
+
docstring/type-hint coverage, and more).
|
|
13
|
+
structure -- analyze_python_structure: class-by-class,
|
|
14
|
+
definition-by-definition AST index of a Python
|
|
15
|
+
source file, with line spans.
|
|
16
|
+
pycache-clean -- pycache_cleaner: configurable removal of
|
|
17
|
+
__pycache__ directories and *.pyc/*.pyo files
|
|
18
|
+
across one or more directory trees.
|
|
19
|
+
init-test-harness -- scaffolds the CONTRACT.md-governed single-test
|
|
20
|
+
harness (run_test.py) into a target repository.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
from __future__ import annotations
|
|
24
|
+
|
|
25
|
+
__version__ = "0.1.0"
|
|
26
|
+
|
|
27
|
+
__all__ = ["__version__"]
|
somnus_debug/cli.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Unified dispatcher for the somnus-debug toolkit.
|
|
2
|
+
|
|
3
|
+
Each tool in this package (`doctor`, `structure`, `pycache-clean`,
|
|
4
|
+
`init-test-harness`) keeps its own independent argparse surface -- that is
|
|
5
|
+
intentional, since they were built and are still usable as standalone
|
|
6
|
+
scripts. This module is a thin router: it picks the subcommand off argv[0]
|
|
7
|
+
and hands the remaining arguments to that tool's own ``main()`` untouched,
|
|
8
|
+
rather than re-declaring every flag in a second parser that could drift out
|
|
9
|
+
of sync with the real one.
|
|
10
|
+
|
|
11
|
+
Installed as the ``somnus-debug`` console script. Individual tools are also
|
|
12
|
+
installed as their own scripts (``somnus-doctor``, ``somnus-structure``,
|
|
13
|
+
``somnus-pycache-clean``) for muscle-memory / CI-script compatibility with
|
|
14
|
+
how they were invoked before packaging.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
19
|
+
import sys
|
|
20
|
+
from typing import Sequence
|
|
21
|
+
|
|
22
|
+
from . import __version__
|
|
23
|
+
from .doctor.core import main as _doctor_main
|
|
24
|
+
from .pycache_cleaner.core import main as _pycache_main
|
|
25
|
+
from .structure.core import main as _structure_main
|
|
26
|
+
from .test_harness.scaffold import main as _scaffold_main
|
|
27
|
+
|
|
28
|
+
_SUBCOMMANDS = {
|
|
29
|
+
"doctor": ("somnus-debug doctor", _doctor_main),
|
|
30
|
+
"structure": ("somnus-debug structure", _structure_main),
|
|
31
|
+
"pycache-clean": ("somnus-debug pycache-clean", _pycache_main),
|
|
32
|
+
"init-test-harness": ("somnus-debug init-test-harness", _scaffold_main),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_TOP_LEVEL_HELP = f"""\
|
|
36
|
+
somnus-debug {__version__} -- Somnus Sovereign Systems Python developer toolkit
|
|
37
|
+
|
|
38
|
+
Usage:
|
|
39
|
+
somnus-debug <command> [command args...]
|
|
40
|
+
|
|
41
|
+
Commands:
|
|
42
|
+
doctor Production-readiness diagnostics (AST-based).
|
|
43
|
+
structure Class/definition index for a single Python file.
|
|
44
|
+
pycache-clean Remove __pycache__/*.pyc/*.pyo across directory trees.
|
|
45
|
+
init-test-harness Scaffold the CONTRACT.md single-test harness into a repo.
|
|
46
|
+
|
|
47
|
+
Each command owns its own --help; run e.g. `somnus-debug doctor --help`.
|
|
48
|
+
Every command is also installed as its own script (somnus-doctor,
|
|
49
|
+
somnus-structure, somnus-pycache-clean).
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _run_subcommand(name: str, argv: Sequence[str]) -> int:
|
|
54
|
+
"""Rewrite sys.argv for the target tool's own argparse and invoke it.
|
|
55
|
+
|
|
56
|
+
The wrapped tools were written as standalone scripts: some accept an
|
|
57
|
+
explicit ``argv`` parameter, others parse ``sys.argv`` internally. We
|
|
58
|
+
normalize by always setting ``sys.argv`` to what the tool would have
|
|
59
|
+
seen if invoked directly (its own program name plus the remaining
|
|
60
|
+
args), so both calling conventions behave identically to running the
|
|
61
|
+
original script.
|
|
62
|
+
"""
|
|
63
|
+
prog, entry_point = _SUBCOMMANDS[name]
|
|
64
|
+
old_argv = sys.argv
|
|
65
|
+
sys.argv = [prog, *argv]
|
|
66
|
+
try:
|
|
67
|
+
result = entry_point(list(argv)) if name != "pycache-clean" else entry_point()
|
|
68
|
+
except SystemExit as exc:
|
|
69
|
+
return int(exc.code) if isinstance(exc.code, int) else 1
|
|
70
|
+
finally:
|
|
71
|
+
sys.argv = old_argv
|
|
72
|
+
return int(result) if isinstance(result, int) else 0
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
76
|
+
"""Entry point for the ``somnus-debug`` console script."""
|
|
77
|
+
argv = list(sys.argv[1:] if argv is None else argv)
|
|
78
|
+
|
|
79
|
+
if not argv or argv[0] in ("-h", "--help"):
|
|
80
|
+
print(_TOP_LEVEL_HELP)
|
|
81
|
+
return 0
|
|
82
|
+
if argv[0] in ("-V", "--version"):
|
|
83
|
+
print(__version__)
|
|
84
|
+
return 0
|
|
85
|
+
|
|
86
|
+
command, rest = argv[0], argv[1:]
|
|
87
|
+
if command not in _SUBCOMMANDS:
|
|
88
|
+
print(f"somnus-debug: unknown command {command!r}\n", file=sys.stderr)
|
|
89
|
+
print(_TOP_LEVEL_HELP, file=sys.stderr)
|
|
90
|
+
return 2
|
|
91
|
+
|
|
92
|
+
return _run_subcommand(command, rest)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
if __name__ == "__main__":
|
|
96
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Python Production Doctor: AST-based production-readiness diagnostics.
|
|
2
|
+
|
|
3
|
+
Original single-file implementation lives in ``core.py`` (moved verbatim
|
|
4
|
+
from the repo-root ``python_production_doctor.py`` during packaging; see
|
|
5
|
+
that module's docstring for provenance and modification history). This
|
|
6
|
+
``__init__`` only re-exports the entry point used by the toolkit CLI.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
from .core import main
|
|
12
|
+
|
|
13
|
+
__all__ = ["main"]
|