Skip to content

Incorrect (or absent) error message for DefaultDict #2986

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

Closed
ilevkivskyi opened this issue Mar 10, 2017 · 3 comments · Fixed by python/typeshed#1456
Closed

Incorrect (or absent) error message for DefaultDict #2986

ilevkivskyi opened this issue Mar 10, 2017 · 3 comments · Fixed by python/typeshed#1456
Assignees
Labels
bug mypy got something wrong priority-1-normal

Comments

@ilevkivskyi
Copy link
Member

With this code:

from typing import DefaultDict
from collections import defaultdict

d: DefaultDict[str, int]
d[1] = 2

mypy shows a strange error (note "dict" instead of "DefaultDict"):

error: Invalid index type "int" for "dict"; expected type "str"

Moreover, if I remove the (redundant) import from collections, then mypy passes without errors.

@ilevkivskyi
Copy link
Member Author

ilevkivskyi commented Mar 10, 2017

Since it looks like this bug was introduced by my old PR, I will fix this. You could assign this issue to me (I can't do this myself).

@ilevkivskyi ilevkivskyi self-assigned this Mar 31, 2017
@ilevkivskyi
Copy link
Member Author

This was partially fixed by #3147, now the error message correctly mentions defaultdict[str, int] instead of just dict. However, still the message disappears if redundant collections import is removed.

@ilevkivskyi
Copy link
Member Author

This is now fixed by python/typeshed#1456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-1-normal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant