Skip to content

fix(parser): track keyword argument callback references - #855

Merged
tirth8205 merged 2 commits into
tirth8205:mainfrom
lamchun1110:fix/keyword-argument-callback-refs
Aug 19, 2026
Merged

fix(parser): track keyword argument callback references#855
tirth8205 merged 2 commits into
tirth8205:mainfrom
lamchun1110:fix/keyword-argument-callback-refs

Conversation

@lamchun1110

Copy link
Copy Markdown
Contributor

Summary

  • extract Python callback references from keyword_argument values
  • reuse the existing known-definition/import guard to avoid noisy edges
  • add regression coverage for set_defaults(func=handler) and dead-code detection

Fixes #840

Testing

  • uv run pytest tests/test_parser.py -q --disable-warnings --maxfail=1 (163 passed)
  • uv run pytest tests/ --tb=short -q (2399 passed, 5 skipped, 2 xpassed)
  • uv run ruff check code_review_graph/parser.py
  • uv run mypy code_review_graph/ --ignore-missing-imports --no-strict-optional

@lamchun1110
lamchun1110 marked this pull request as ready for review August 15, 2026 12:19
@github-actions

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.30 (LOW) — 7 changed function(s)/class(es), 0 affected flow(s), 4 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.30 low code_review_graph/parser.py::CodeParser code_review_graph/parser.py:2404 yes
0.30 low tests/fixtures/sample_callback_refs.py::keyword_callback tests/fixtures/sample_callback_refs.py:22 no
0.30 low tests/fixtures/sample_callback_refs.py::register_keyword_callback tests/fixtures/sample_callback_refs.py:42 no
0.25 low code_review_graph/parser.py::CodeParser._ref_from_arguments code_review_graph/parser.py:12184 no
0.05 low tests/test_parser.py::TestCodeParser tests/test_parser.py:13 no
0.05 low tests/test_parser.py::TestCodeParser.test_python_keyword_callback_reference_emitted tests/test_parser.py:845 (test)
0.05 low tests/test_parser.py::TestCodeParser.test_python_callback_references_not_treated_as_dead tests/test_parser.py:852 (test)

Test gaps

  • code_review_graph/parser.py::CodeParser._ref_from_arguments (code_review_graph/parser.py:12184)
  • tests/fixtures/sample_callback_refs.py::keyword_callback (tests/fixtures/sample_callback_refs.py:22)
  • tests/fixtures/sample_callback_refs.py::register_keyword_callback (tests/fixtures/sample_callback_refs.py:42)
  • tests/test_parser.py::TestCodeParser (tests/test_parser.py:13)

Token savings: this graph-backed report used ~187,072 fewer tokens (~99%) than reading every changed file in full (estimated, chars/4 approximation).


Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

@tirth8205

Copy link
Copy Markdown
Owner

Verified the new tests fail without the parser change and that builtins and keyword names get no spurious edges. Merging. Bound method callbacks like cb=self.on_event are still not covered, consistent with the scope cut in #424.

@tirth8205
tirth8205 merged commit 3337ed0 into tirth8205:main Aug 19, 2026
13 checks passed
@lamchun1110
lamchun1110 deleted the fix/keyword-argument-callback-refs branch August 19, 2026 00:48
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.

dead_code false positive: keyword-argument callback refs (argparse set_defaults(func=...)) — gap left open by #363/#424

2 participants