-
-
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
Unexpected behaviour when using None as generic argument #2230
Comments
As a clarification, this happens with |
Probably there's some confusion due to partial types (the {} and [] trigger
that). @ddfisher what do you think?
|
There are two things going on here:
from typing import List, Optional
def f(lst: List[Optional[int]]): pass
x = [None]
f(x) Currently, this gives a |
OK, I understand the motivation behind 2. Perhaps a more explicit error message would have helped, I got used to read "Need type annotation for variable" as "mypy doesn't have enough information to infer this type", but in this case is "mypy decided to not infer this type because it will be probably wrong". The example I mentioned is also a bit different because |
Right now only the last two error messages still appear. |
I'm going to close this issue because problem 1 is fixed. I've made a new issue to track problem 2: #2246. |
I'm trying the following code
Which reports 4 errors (2 for list and 2 for dict) which I think are all incorrect:
Dict[None, None]
should be{}
and{None: None}
, the valid values forList[None]
should be[]
and[None]*
k for any natural number k)Using generics different than
None
works fine.The text was updated successfully, but these errors were encountered: