Skip to content

fix(python): eliminate call-graph ledger FPs/FNs (nested classes, multiline annotations, cross-newline non-calls) - #8792

Closed
squid-protocol wants to merge 1 commit into
mainfrom
fix/python-call-graph-ledger
Closed

squid-protocol wants to merge 1 commit into
mainfrom
fix/python-call-graph-ledger

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Consolidates all actionable Python call-graph comparison ledger fixes into a single PR:

  1. Nested class headers (python/call/not-a-call-in-ts:class_definition<block, 30 FPs)
    • Added CALLS_OUT_PYTHON in gitgalaxy/standards/language_standards/_shared_patterns.py (registered in QUALIFIED_CALLS_OUT_PATTERNS) with (?<!\bclass )(?<!\bclass\t) lookbehind so nested class Model(BaseModel): inside a function body is not captured as a call to Model.
  2. Cross-newline non-calls (not-a-call-in-ts:assignment<block, parameters<function_definition, 2 FPs)
    • CALLS_OUT_PYTHON matches [ \t]*\( instead of \s*\( so a newline-separated statement (False\n\n(l, rl) = ..., m1\n(dtype1, dtype2) = ...) is never treated as a call.
    • Added "True", "False", "None" to Python's _calls_out_ignore.
  3. Multi-line bracketed return annotations (inner-named-function_definition, 10 FPs; engine-attributes-to-another-function, 6 FNs)
    • In StructuralExtractor._slice_by_indentation (gitgalaxy/core/detector.py), initialize bracket_depth from unclosed brackets in safe_code[sig_scan:scan_pos] when track_brackets is active, so async def _sse_producer_cm() -> AsyncIterator[\n ObjectReceiveStream[bytes]\n]: keeps its full body span instead of terminating at ]: and properly blanks its calls from the enclosing function.

Golden Crucible Updates

  • Updated tests/golden_master_audit and tests/golden_master_zero_dep_audit via crucible_check.py --update --yes. All structural diffs are Python files reflecting the eliminated FPs and restored nested-function call attribution (fastapi/routing.py, fastapi/tests/test_compat.py and other nested-class tests, numpy/crackfortran.py, numpy/core.py, twisted/defer.py, NVDA/core.py, MemoryView.pyx).

Verification

  • Added tests/extraction/languages/test_calls_out_python_ledger.py covering all three classes plus qualifier preservation.
  • Updated CALLS_OUT_PYTHON pattern assertions in test_calls_out_keywords_3359.py and test_calls_out_generics_3644.py.
  • Ran pytest tests/extraction/languages/test_calls_out_*.py (1322/1322 passed after assertion update), tests/extraction/languages/test_python*.py (234/234 passed), tests/core_engine/test_call_resolver.py, ruff format --check, tests/ruff_audit.py --ci, tests/doc_refs_audit.py --ci, and python tests/tools/call_graph_resolution.py python --ci (all passed).

…tiline annotations, cross-newline non-calls)
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol

Copy link
Copy Markdown
Owner Author

Consolidated into #8795 (rebased cleanly onto main after #8632 merged) to avoid golden-crucible merge conflicts and save CI runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant