-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
False positive TCH003 fix for singledispatch functions with type annotations (redux) #13955
Comments
Can you specify what Ruff version do you have? And also provide the Ruff config if any is being used in your command invocation? I'm unable to reproduce this: https://play.ruff.rs/6e46194f-daf9-4a61-98ce-c3d1bccf019e |
Note that the linked issue also included a ruff config necessary to reproduce the previous bug report. That is still necessary here -- all I did was extend/enhance the I'm using ruff 0.7.1 |
I updated your playground case: https://play.ruff.rs/ab7beaa2-920d-4ef4-905e-1bbfd97d8719 |
Got it, thanks! |
## Summary fixes: #13955 ## Test Plan Update existing test case to use a return type hint for which `main` flags `TCH003`.
#11520 again
Consider the same code block from there again:
but tweaked a bit. Now the function also returns an imported type too.
The underlying issue is that in order for singledispatch to learn about the annotations of the decorated function, it has to run an introspection that doesn't distinguish between what singledispatch needs and what singledispatch doesn't need.
This was fixed in #11523 by "treating all singledispatch arguments as runtime-required" -- but it's not about the arguments, it's about the function signature. Return values, too, are part of the function signature.
The text was updated successfully, but these errors were encountered: