Add test coverage for sys.modules fallback path in get_scope#188
Merged
samwaseda merged 4 commits intosamwaseda-patch-1from Mar 18, 2026
Merged
Add test coverage for sys.modules fallback path in get_scope#188samwaseda merged 4 commits intosamwaseda-patch-1from
samwaseda merged 4 commits intosamwaseda-patch-1from
Conversation
Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Change get_scope parameter type from FunctionType to object
Add test coverage for sys.modules fallback path in get_scope
Mar 18, 2026
Member
|
@copilot run black |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## samwaseda-patch-1 #188 +/- ##
=====================================================
+ Coverage 97.92% 97.97% +0.04%
=====================================================
Files 34 34
Lines 2268 2268
=====================================================
+ Hits 2221 2222 +1
+ Misses 47 46 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
Both changed files are already black-formatted — no changes needed. |
Member
|
@copilot Remove |
Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Contributor
Author
samwaseda
reviewed
Mar 18, 2026
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
get_scope's fallback branch (module = sys.modules.get(module_name), line 53) was unreachable by existing tests becauseinspect.getmoduleinternally callssys.modules.get(object.__module__)— meaning if the module is insys.modules, it never returnsNoneand the fallback is skipped entirely. This PR adds test coverage for that path and fixes repository hygiene by removing a generated file from version control.Related Issue(s)
Backward Compatibility
No change to production code — test-only addition.
Implementation Notes
tests/unit/models/parsers/test_object_scope.pytest_sys_modules_fallback_when_getmodule_returns_none: patchesinspect.getmoduleto returnNone(simulating C-extension types or other objects where module resolution fails), then verifies the fallback correctly resolves the module viasys.modules.get(module_name)and returns a validScopeProxyfrom unittest.mock import patchimportRemoved accidentally committed
flowrep/_version.py(a setuptools-scm generated file that explicitly states "don't track in version control") and added*/_version.pyto.gitignoreto prevent recurrence.The fallback path exists for objects (e.g. C-extension callables) where
inspect.getmodulemay fail even though a valid__module__attribute is present. Mocking is the only reliable way to exercise this path in isolation, since naturally the twosys.moduleslookups would always agree.📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.