Fix AttributeError in get_scope when inspect.getmodule() returns None#187
Merged
samwaseda merged 5 commits intosamwaseda-patch-1from Mar 18, 2026
Merged
Fix AttributeError in get_scope when inspect.getmodule() returns None#187samwaseda merged 5 commits intosamwaseda-patch-1from
samwaseda merged 5 commits intosamwaseda-patch-1from
Conversation
…lear ValueError Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [WIP] Address feedback on get_scope parameter type change in PR #186
Fix AttributeError in get_scope when inspect.getmodule() returns None
Mar 18, 2026
Member
|
@copilot Remove the |
Member
|
@copilot run black |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## samwaseda-patch-1 #187 +/- ##
=====================================================
- Coverage 97.96% 97.92% -0.04%
=====================================================
Files 34 34
Lines 2260 2268 +8
=====================================================
+ Hits 2214 2221 +7
- Misses 46 47 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…gitignore Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Contributor
Author
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_scopecalledinspect.getmodule(func).__dict__unconditionally. With the parameter type widened toobject,inspect.getmodule()returningNone(builtins, dynamically-created objects) became easy to trigger, raising an opaqueAttributeErroronNoneType.Related Issue(s)
Addresses review feedback on #186.
Backward Compatibility
No breaking changes. The function previously crashed with
AttributeErrorin theNonecase; it now raises a descriptiveValueErrorinstead. Normal callsites are unaffected.Detailed Description
get_scopenow:inspect.getmodule(func)forNoneNone, falls back viagetattr(func, "__module__", None)+sys.modules.get()ValueErrorTwo new tests cover the fallback path and the
ValueErrorcase. Code has been formatted withblack.flowrep/_version.py(a setuptools-scm build artifact) was also removed from version control and added to.gitignoreto prevent it from being accidentally committed in the future.💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.