-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Mypy is expecting type[Never]
in context when it shouldn't
#18968
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
Comments
In this case, I think it's because mypy thinks I guess mypy could guess the first argument's type based on |
Your decorator is a descriptor, yes, but it doesn't mean it takes a There's a trivial approach to this problem (~50 LOC + tests, I believe) - we could introduce One alternative approach is providing a |
hey @sterliakov, thanks for the reply. the flags sound cool, though i'm not sure i understand their usage? you would pass them in your config (or as a cli arg) and they would change how these methods are analysed? or you would pass them alongside the relevant lines of code somehow? thanks :) |
Yes, I mean config/CLI flags, so that invoking |
Could we maybe infer the (Is that information too late to use? Or some gotcha...) |
hey @sterliakov -- that sounds good to me! |
Bug Report
I have written (well, copied, from here) a class
classproperty
to handle implementing class properties. It works perfectly fine, however when I try and type it as follows (which I think is valid),mypy
raises the below errorI don't think this is correct, based on my understanding of descriptors and
__get__
. I asked a question on stackoverflow about this and it was suggested that this is caused by incorrect assumptions about how__get__
is calledTo Reproduce
Gist link here
Expected Behavior
Mypy should pass
Actual Behavior
Your Environment
mypy==1.15.0
No further config
The text was updated successfully, but these errors were encountered: