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

Detect missing typehint early #120

Merged
merged 2 commits into from
Feb 8, 2024
Merged

Conversation

jl-wynen
Copy link
Member

@jl-wynen jl-wynen commented Feb 7, 2024

Fixes #115

kwargs = {name: hints[name] for name in signature.kwonlyargs}
except KeyError:
raise ValueError(
f'Provider {provider} lacks type-hint for arguments.'
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
f'Provider {provider} lacks type-hint for arguments.'
f'Provider {provider} lacks type-hint for arguments or return value.'

Copy link
Member Author

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

Comment on lines -178 to +180
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}
Copy link
Member

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)?

Copy link
Member Author

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.

@SimonHeybrock SimonHeybrock mentioned this pull request Feb 8, 2024
@jl-wynen jl-wynen enabled auto-merge February 8, 2024 08:28
@jl-wynen jl-wynen merged commit 95ef23e into main Feb 8, 2024
5 checks passed
@jl-wynen jl-wynen deleted the detect-missing-typehints-early branch February 8, 2024 08:30
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.

Earlier detection of missing type hints
2 participants