Skip to content

Change get_scope parameter type from FunctionType to object#186

Merged
samwaseda merged 19 commits intomainfrom
samwaseda-patch-1
Mar 18, 2026
Merged

Change get_scope parameter type from FunctionType to object#186
samwaseda merged 19 commits intomainfrom
samwaseda-patch-1

Conversation

@samwaseda
Copy link
Member

I would like to use it for class objects as well, in which case FunctionType is not broad enough.

@samwaseda samwaseda requested review from Copilot and liamhuber March 18, 2026 10:48
@github-actions
Copy link

Binder 👈 Launch a binder notebook on branch pyiron/flowrep/samwaseda-patch-1

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.97%. Comparing base (507e9b2) to head (3c260aa).
⚠️ Report is 20 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #186   +/-   ##
=======================================
  Coverage   97.96%   97.97%           
=======================================
  Files          34       34           
  Lines        2259     2268    +9     
=======================================
+ Hits         2213     2222    +9     
  Misses         46       46           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR broadens flowrep.models.parsers.object_scope.get_scope’s type annotation so it can be used with class objects (not only FunctionType), enabling scope extraction for additional callable-like objects during parsing.

Changes:

  • Remove FunctionType import and widen get_scope’s parameter type hint to object.
  • Keep scope construction logic based on the module globals plus builtins.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

samwaseda and others added 2 commits March 18, 2026 11:54
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Mar 18, 2026

@samwaseda I've opened a new pull request, #187, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 5 commits March 18, 2026 11:00
…lear ValueError

Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
…gitignore

Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Fix AttributeError in get_scope when inspect.getmodule() returns None
Copy link
Member

@liamhuber liamhuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! Good extension. I don't see any conceptual concern broadening the type here. As long as it works for some broader testing, I'm totally happy.

Codecov is complaining in one spot that should be easy to cover -- so easy that I'm confused why your current tests aren't covering it.

The other thing I'd like to see is some "rubber meets the road" tests of actual other callables. A builtin callable like int, a class, and a class method all come to mind, but a decent LLM might think of an edge case I'm missing.

if module is None:
module_name = getattr(func, "__module__", None)
if module_name is not None:
module = sys.modules.get(module_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codecov is showing that this line is not covered. I'd like to get it fully covered, but I'm a little confused because it looks to me like test_none_module_fallback_via_dunder_module should be hitting this?

@samwaseda
Copy link
Member Author

@copilot Write a unit test to cover the line module = sys.modules.get(module_name)

Copy link
Contributor

Copilot AI commented Mar 18, 2026

@samwaseda I've opened a new pull request, #188, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 4 commits March 18, 2026 14:57
Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Add test coverage for sys.modules fallback path in get_scope
@samwaseda samwaseda requested a review from liamhuber March 18, 2026 15:23
@samwaseda
Copy link
Member Author

@copilot Address @liamhuber's above comment: "The other thing I'd like to see is some "rubber meets the road" tests of actual other callables. A builtin callable like int, a class, and a class method all come to mind, but a decent LLM might think of an edge case I'm missing."

Copy link
Contributor

Copilot AI commented Mar 18, 2026

@samwaseda I've opened a new pull request, #189, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 5 commits March 18, 2026 15:53
…ypes

Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Co-authored-by: Liam Huber <liamhuber@greyhavensolutions.com>
Add tests for get_scope with builtin types, classes, and methods
@samwaseda samwaseda merged commit ef7ec85 into main Mar 18, 2026
20 checks passed
@samwaseda samwaseda deleted the samwaseda-patch-1 branch March 18, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants