Repository navigation
fix(python): respect lambda parameter shadowing in call edges - #5417
melhusl-hs wants to merge 2 commits into
Conversation
|
Thanks for the pull request, @melhusl-hs. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify review 
3 possible issues to check · High impact
The AST cache schema is advanced to invalidate fragments produced before the lambda-shadowing change.
3 possible issues we couldn't confirm
- Lambda parameter shadowing may go undetected if lambda parameters are not read by
_python_param_names·graphify/extractors/engine.py:11470 - Comprehension variables that shadow a module function still produce a call edge ·
graphify/extractors/engine.py:12345 - Cache-reuse test loop never confirms the second pass reads from cache ·
tests/test_python_lambda_call_shadowing.py:117
They don't change the score.
What this review covered
- We didn't review 1 file that isn't source code, such as docs, config, images, or generated or third-party code.
- Some lookups asked for files or lines that do not exist; the review was told and carried on.
- 3 of 3 changed files inspected. This is scope, not a correctness guarantee.
Code graph · 5029 functions depend on this change
- 2 functions became more coupled.
extract()(1351 callers),walk_calls()(1 callers). - 621 of 621 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed 9bf28d0 · 2 earlier findings not re-checked · Full report in the Graphify check
Check the lambda body scope before resolving a bare call or callback reference. Defaults still see the enclosing bindings. Bump the AST cache schema so older extraction fragments cannot return the false edges. Related: Graphify-Labs#3607 Co-Authored-By: Codex <[email protected]>
3d8fa1a to
36ac153
Compare
Apply Python identifier normalization and class-private mangling to lambda bindings. Clarify the default-expression guarantee while enclosing-function lookup is tracked separately in Graphify-Labs#5418. Co-Authored-By: Codex <[email protected]>
36ac153 to
9bf28d0
Compare
…batch Fold the Python-lambda (#5417), Go-import-shadow (#5411) and COBOL GO-TO (#5423) AST-output changes into one combined _AST_CACHE_SCHEMA bump 53 -> 54, so cached Python/Go/COBOL extractions re-run. Fix the #5422 regression test's cwd-fragile `query` assertion to check the queried node (returncode==0 is the real invariant). 0.9.119 changelog and version bump. The headline is the #5320 anyio regression fix (graph commands broke on core installs in 0.9.118). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in v0.9.119 via an authorship-preserving cherry-pick. A call to a name a lambda parameter shadows no longer binds to a module-level definition inside the lambda body, scoped to the body only. Thanks @melhusl-hs! |
What does this PR do?
Respect Python lambda parameter bindings when resolving bare calls and callback arguments. A lambda parameter shadows same-named file or corpus callables inside its body, while defaults still resolve in the enclosing scope. Identifier comparison follows NFKC normalization and class-private name mangling. Bump the AST cache schema from 53 to 54 so cached fragments are re-extracted.
Related to #3607. Enclosing function parameters are handled separately in #5419; its cache-schema update and this PR will need coordination if either merges first.
Validation
5ce8fceff41d1b636f872b6206b917ec2af7ac54).ruff checkpassed for the changed Python files;git diff --checkpassed.graphify update .completed locally with the model backend disabled.The earlier full-suite and schema-51 migration results were obtained before this rebase and do not qualify the new head. No API keys or private source content are included. Material AI assistance is disclosed in the commit metadata.