mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 20:27:02 +01:00
_analyzer.py 388 -> 226. The file walk, dotted-name map, import resolution and fingerprint go to _deps.py; the skip frozensets and the function regex to _scan_tables.py, which covered the last nine lines after the first cut landed at 259. _is_binary is the only name any test patches on _analyzer and it stays put, so no patch string needed editing. Only test_analyzer.py's import block had to be split. Pass count is 216 before and after. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
52 lines
3.5 KiB
JSON
52 lines
3.5 KiB
JSON
{
|
|
"intent": "Bring code_tutor/_analyzer.py under the 250-line cap by separating the import-graph half and the static scan tables, with no behaviour change.",
|
|
"scope": [
|
|
"python_pkg/code_tutor/_deps.py, _scan_tables.py (new)",
|
|
"python_pkg/code_tutor/_analyzer.py (388 -> 226)",
|
|
"python_pkg/code_tutor/cli.py, _plan_builder.py (import paths only)",
|
|
"python_pkg/code_tutor/tests/test_analyzer.py (import path only)",
|
|
"Non-goal: no assertion changed, no test deleted, skipped or weakened"
|
|
],
|
|
"changes": [
|
|
"Moved get_python_files, _build_dotted_map, _match_deps, get_file_imports and codebase_fingerprint into _deps.py, which imports _should_skip back from _analyzer and owns the hashlib import it was the only user of.",
|
|
"Moved the _SKIP_DIRS, _SKIP_SUFFIXES and _OTHER_LANGS frozensets and the _FUNCTION_RE pattern into _scan_tables.py. The first cut left _analyzer.py at 259, nine over; these tables are pure data with no patch targets, which made them the cheapest remaining lines.",
|
|
"cli.py and _plan_builder.py import the moved functions from _deps directly. test_analyzer.py's single import block was split across the two modules.",
|
|
"_is_binary is the only name any test patches on _analyzer, and it stays there, so no patch string in the package needed editing - a much cheaper seam than the _challenge one."
|
|
],
|
|
"verification": [
|
|
{
|
|
"command": "timeout 90 env PYTHONPATH=. python3 -m pytest python_pkg/code_tutor/tests -q",
|
|
"result": "pass",
|
|
"evidence": "216 passed in 2.2s - identical to the baseline count, and inside the timeout that the previous commit's hang made standard here."
|
|
},
|
|
{
|
|
"command": "timeout 90 env PYTHONPATH=. python3 -m pytest python_pkg/code_tutor/tests -q (first run)",
|
|
"result": "fail then pass",
|
|
"evidence": "One collection ImportError: test_analyzer.py imports _build_dotted_map and four other moved names from _analyzer. Its import block was split across the two modules and the run returned to 216."
|
|
},
|
|
{
|
|
"command": "PYTHONPATH=. python3 -c \"from python_pkg.code_tutor import _analyzer as a, _deps as d, cli, _plan_builder as pb, _scan_tables as t; a._is_binary; a._SKIP_DIRS; a._FUNCTION_RE; d.get_file_imports; d._should_skip; d.hashlib; cli.codebase_fingerprint; pb.get_python_files\"",
|
|
"result": "pass",
|
|
"evidence": "all patch targets resolve - including cli.codebase_fingerprint, which three test_cli.py patches name and which still resolves because cli imports it from its new home."
|
|
},
|
|
{
|
|
"command": "wc -l python_pkg/code_tutor/_analyzer.py python_pkg/code_tutor/_deps.py python_pkg/code_tutor/_scan_tables.py",
|
|
"result": "pass",
|
|
"evidence": "226, 145 and 48 lines, all under the 250-line cap."
|
|
},
|
|
{
|
|
"command": "pre-commit run --files <the touched files and artifacts>",
|
|
"result": "pass",
|
|
"evidence": "ruff auto-sorted six import statements across the new and edited modules; clean on re-run, and pytest-with-coverage passes."
|
|
}
|
|
],
|
|
"risks": [
|
|
"_analyzer <- _deps and _analyzer <- _scan_tables must stay one-way; _analyzer importing from _deps would be a cycle, and _deps already imports _should_skip from _analyzer.",
|
|
"The scan tables are now two modules away from the extraction code that reads them, so a future skip-list change has to be made in _scan_tables rather than where it is used."
|
|
],
|
|
"rollback": [
|
|
"git revert the commit; _analyzer.py returns to 388 lines and the two new modules disappear.",
|
|
"After rollback, re-run the package suite and confirm it still reports 216 passed."
|
|
]
|
|
}
|