feat: add globals if available - #319
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates scope resolution for parsing by merging a callable’s __globals__ (when present) into the resolved module scope, ensuring name lookups work even when inspect.getmodule() returns a module that isn’t actually the function’s defining global namespace.
Changes:
- Extend
get_scopeto includefunc.__globals__when available, before adding builtins. - Add a unit test asserting that function globals are preferred when the resolved module is unrelated.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/unit/parsers/test_object_scope.py | Adds coverage for resolving names via a function’s __globals__ even when inspect.getmodule() indicates an unrelated module. |
| src/flowrep/parsers/object_scope.py | Merges module globals with __globals__ (if present) before constructing the ScopeProxy and adding builtins. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #319 +/- ##
=======================================
Coverage 99.94% 99.94%
=======================================
Files 44 44
Lines 3569 3586 +17
=======================================
+ Hits 3567 3584 +17
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
According to copilot, the problem I encounter here can be resolved with this change. Let's see.