Detect local arguments and functions used in a function#190
Merged
Conversation
Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Detect local arguments and functions used in a function
Detect local arguments and functions used in a function
Mar 19, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## args #190 +/- ##
==========================================
+ Coverage 97.47% 97.65% +0.18%
==========================================
Files 34 34
Lines 2295 2305 +10
==========================================
+ Hits 2237 2251 +14
+ Misses 58 54 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds AST-based undefined-variable detection to
dependency_parserso that external symbols used by a function can be identified and resolved for dependency tracking. Local (nested) function definitions are explicitly forbidden—raisingNotImplementedErrorearly—to avoid silent mis-resolution rather than producing incorrect dependency graphs.Related Issue(s)
Follow-up to #155.
Backward Compatibility
Functions containing nested
deforasync defblocks will now raiseNotImplementedErrorwhen passed tofind_undefined_variablesorget_call_dependencies. Previously these were silently (and incorrectly) processed.Implementation Notes
UndefinedVariableVisitor— rewrites the AST visitor with a_nesting_depthcounter. AnyFunctionDef/AsyncFunctionDefencountered at depth > 0 raisesNotImplementedErrorwith a message that distinguishesdeffrom ``async def`:posonlyargs,args,kwonlyargs,*args,**kwargs) indefined_vars, eliminating false positives from these names.get_call_dependencies— resolves each undefined symbol viaobject_scopeand recursively collects unversioned objects.test_local_function_definition_raises/test_local_async_function_definition_raises— verify the new early-failure behavior.test_all_argument_kinds_are_defined— guards against regression on argument-kind coverage.📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.