-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Overloads with None don't work #1399
Comments
As an ugly workaround, I can define a
|
Yeah, mypy currently treats The easiest way to get mypy to tell you what type it has inferred for a given variable is usually to use it in a blatantly incorrect way -- then it will show you the type in the error message. (It would be nice if there was a better idiom for this. Maybe a special annotation like |
Yeah, a "blatantly incorrect" usage is exactly what I was hoping for with |
I used pdb to look into this and it does seem to be Any. |
Related issue: #1322 ( |
We should address this when we do the work on strict Optional checking. |
Would be fixed by #1278, which is likely to be part of strict Optional checking. |
This seems to be fixed now (there is no error). |
Seems still an issue with classmethod's overloads at least:
If i use it:
The |
Please open a new issue if you think something is wrong, rather than posting on a vaguely related long-closed one. Try putting the None overload first. |
This example (straight out of the PEP, in a stub file instead of a source file) doesn't pass mypy's type checking:
It looks like
None
is being interpreted as something broader, when at least for overload resolution it just means the exact value None and shouldn't overlap with any non-optional type.Related to #885.
The text was updated successfully, but these errors were encountered: