-
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
Detect missing typehint early #120
Conversation
kwargs = {name: hints[name] for name in signature.kwonlyargs} | ||
except KeyError: | ||
raise ValueError( | ||
f'Provider {provider} lacks type-hint for arguments.' |
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.
f'Provider {provider} lacks type-hint for arguments.' | |
f'Provider {provider} lacks type-hint for arguments or return value.' |
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.
No, that is handled separately
args = {name: hints[name] for name in signature.args} | ||
kwargs = {name: hints[name] for name in signature.kwonlyargs} | ||
try: | ||
args = {name: hints[name] for name in signature.args} | ||
kwargs = {name: hints[name] for name in signature.kwonlyargs} |
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.
So why did this not raise before? This looks the same to me (apart from a better exception message)?
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.
Correct. When I initially said
It pushes the detection forward to pipeline.get. But not to the constructor.
I hadn't implemented the Provider
class yet. But since I implemented it, the missing type hint was already detected during Pipeline construction.
So yes, this PR only improves the error message.
Fixes #115