Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] Allow _FactoryMade to explicitly define where its reduce should import from #27

Merged
merged 6 commits into from
Aug 8, 2024

Conversation

liamhuber
Copy link
Member

@liamhuber liamhuber commented Aug 8, 2024

When a @classfactory is used inside a decorator, i.e. to create a new class directly from a decorated function or class definition, the new _FactoryMade class automatically conflicts with the namespace of its underlying source material. Previously, you could store the underlying function with _class_returns_from_decorated_function to avoid this conflict. This PR deprecates (but leaves available) that interface, while providing a new _reduce_imports_as: tuple[str, str] allowing you to explicitly specify where the _FactoryMade class should be (re)imported from in __reduce__. IMO this is a bit clearer, and is necessary flexibility for pyiron/pyiron_workflow#410 which is closing pyiron/pyiron_workflow#319.

Copy link

github-actions bot commented Aug 8, 2024

Binder 👈 Launch a binder notebook on branch pyiron/pyiron_snippets/factory_decorated_classes

Copy link

codacy-production bot commented Aug 8, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.03% (target: -1.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (5c2f87a) 556 529 95.14%
Head commit (c591337) 559 (+3) 532 (+3) 95.17% (+0.03%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#27) 3 3 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

@coveralls
Copy link

coveralls commented Aug 8, 2024

Pull Request Test Coverage Report for Build 10295529767

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 95.17%

Files with Coverage Reduction New Missed Lines %
factory.py 2 93.57%
Totals Coverage Status
Change from base Build 10156807263: 0.03%
Covered Lines: 532
Relevant Lines: 559

💛 - Coveralls

@liamhuber liamhuber changed the title Allow _FactoryMade to explicitly define where its reduce should import from [patch] Allow _FactoryMade to explicitly define where its reduce should import from Aug 8, 2024
@liamhuber liamhuber added the format_black Trigger the black formatting bot label Aug 8, 2024
@liamhuber liamhuber marked this pull request as ready for review August 8, 2024 03:39
@liamhuber liamhuber merged commit e0beaa6 into main Aug 8, 2024
19 checks passed
@liamhuber liamhuber deleted the factory_decorated_classes branch August 8, 2024 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
format_black Trigger the black formatting bot
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants