-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Mypy incorrectly determines type #1358
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
Here is another example that shows that something is wrong even without subclassing d = defaultdict(list) # type: defaultdict[int, str] this expectedly fails but the error message shows that the type of first argument
|
Actually, in your second example, However your first issue still stands, and I'll look into why the properties of defaultdict aren't correctly conferred on its subclass. (I have a vague feeling I ran into a similar issue myself recently but can't find anything I might have put in the tracker about it.) |
For the first issue, I'm going to venture a guess that this is one of our numerous issues with generic types, and I'm assigning it to Reid Barton who's looking to become the expert on this topic. |
The error message is indeed a bit misleading, because in another case d = defaultdict(42) # type: defaultdict[int, str] it mentions the type and not the value
|
I think If you wanted
With this change, mypy already accepts the call |
OK, let's close this as a dupe of #1246. |
It looks like #815 has not been fixed completely, here is an example
The text was updated successfully, but these errors were encountered: