Skip to content

mypy accepts tuple[int] etc. #2428

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 Nov 10, 2016 · 1 comment
Closed

mypy accepts tuple[int] etc. #2428

ilevkivskyi opened this issue Nov 10, 2016 · 1 comment
Labels
bug mypy got something wrong priority-1-normal

Comments

@ilevkivskyi
Copy link
Member

mypy currently accepts

tuple[int], list[int], dict[int, str]

while all of those fail at runtime. I think those should be flagged as errors.

@JukkaL
Copy link
Collaborator

JukkaL commented Nov 10, 2016

This is an old bug, but I couldn't find an existing issue. #999 is closely related -- fixing either of these issues would likely make the remaining issue trivial to fix.

@JukkaL JukkaL added the bug mypy got something wrong label Nov 10, 2016
@gvanrossum gvanrossum added this to the 0.5 milestone Nov 10, 2016
gvanrossum pushed a commit that referenced this issue Mar 14, 2017
Fixes #2428

All of the following are now allowed, but fail at runtime:
```
list[int]
dict[int, str]
set[int]
tuple[int]
frozenset[int]
enumerate[int]
collections.defaultdict[int, str]
collections.Counter[str]
collections.ChainMap[str, str]
```
I prohibit those by simply tracking whether a corresponding symbol table node was normalized or not.

@gvanrossum I make an exclusion for stubs, because a have found dozens of places where this is used in typeshed, if you think that it also makes sense to prohibit this in stubs, then I will make an additional PR to typeshed.
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

No branches or pull requests

3 participants