-
Notifications
You must be signed in to change notification settings - Fork 2
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
Support most callables #133
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing a test with classmethod
?
src/sciline/_provider.py
Outdated
if isinstance(func, type): | ||
raise TypeError( | ||
"Classes are not supported as providers because their type annotations " | ||
f"cannot reliably be extracted. Got class {func}. " | ||
"Consider using a free function, classmethod, or staticmethod." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth mentioning that this is about classes, not class instances? While clear to us, an average user may forget to instantiate a class and not know the difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better?
# Drop `self` / `cls` | ||
args = args[1:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if this is a staticmethod
? Does this actually take the inspect.isfunction
branch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. See
sciline/tests/pipeline_test.py
Line 1507 in 1a75b95
def test_pipeline_static_method_provider(deco: Callable[..., Any]) -> None: |
No, it's here: sciline/tests/pipeline_test.py Line 1495 in 1a75b95
|
1a75b95
to
b36dfa9
Compare
Fixes #114