-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Dict, List and Set are imported by default #999
Comments
Ah, seems like a problem with how mypy handles generic type aliases, such as |
FWIW the same thing happens to Set. I don't believe there are other types that have this issue; those three (List, Dict, Set) are treated special by mypy. See https://github.com/python/mypy/blob/master/mypy/nodes.py#L74 |
This is a bit thorny to fix, because Dict/List/Set are currently implemented as aliases to dict/list/set, and all the genericity is specified in typeshed/*/builtins.pyi. I propose not to worry too much about it for 0.3.2. |
Agreed. Maybe move this to 0.3.3? |
Moved to 0.3.3. |
Fix #999 This is a straightforward fix: List, Set, and Dict are treated as aliases to their builtins counterparts, therefore they are ignored by remove_imported_names_from_symtable, I fix this by also removing the alias names. The fix also revealed few places in mypy where imports were missing, and one bug in fastparse.py. Those have been fixed. The fix also includes a typeshed sync at python/typeshed#933.
This code (no import from typing) complains, as expected:
However, this code passes:
Similar with List, Set.
The text was updated successfully, but these errors were encountered: