Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #158 +/- ##
==========================================
- Coverage 98.97% 98.94% -0.04%
==========================================
Files 28 29 +1
Lines 1949 1982 +33
==========================================
+ Hits 1929 1961 +32
- Misses 20 21 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds an import parser to handle local imports in functions, which are not included in function.__globals__. The implementation parses import and from ... import ... statements from function ASTs and builds a scope dictionary that is merged with the module-level scope.
Changes:
- Added
import_parser.pymodule withbuild_scope()function to parse local imports from AST nodes - Modified
CallCollectorincrawler.pyto collect import statements alongside function calls - Extended
get_scope()inobject_scope.pyto accept optional extra modules from local imports - Added integration test to verify local imports are correctly detected in call dependencies
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
flowrep/models/parsers/import_parser.py |
New module that parses AST import nodes and dynamically imports modules to build a scope dictionary |
flowrep/crawler.py |
Extended CallCollector to visit and collect import nodes, integrated import parser into dependency analysis |
flowrep/models/parsers/object_scope.py |
Added optional extra_modules parameter to get_scope() for merging local imports |
tests/unit/test_crawler.py |
Added test function with local imports and integration test validating they are captured |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
I see the necessity for Let me blatantly steal |
|
|
||
| def get_scope(func: FunctionType) -> ScopeProxy: | ||
| return ScopeProxy(inspect.getmodule(func).__dict__ | vars(builtins)) | ||
| def get_scope(func: FunctionType, extra_modules: dict | None = None) -> ScopeProxy: |
There was a problem hiding this comment.
I'm not super comfortable with this. I'd rather leave get_scope alone, and then mutate a ScopeProxy object if and when we know there are new symbols available
Since local imports are not included in
function.__globals__, I added an import parser to complete the scope dictionary, e.g.: