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
OrderedDict
fails disallow_any_generics, but OrderedDict[Any, Any]
doesn't run
#7539
Comments
You can use string literal escapes, such as |
@JukkaL Is there no way to do this without quoting the type? Because even if I
|
You can use |
do you want |
I was going to say that too but it turns out there is no |
there is in 3.7 iirc |
Oh, you're right, it is in 3.7 (https://github.com/python/cpython/blob/3.7/Lib/typing.py) but not in the typing repo (https://github.com/python/typing/blob/master/src/typing.py) where I checked first. I filed python/typing#679 to add it. |
If mypy sees that |
This commit introduces a recommendation for classes that don't support indexing at runtime to be escaped as string literals on missing required generic type args (BARE_GENERIC) error. It should resolve #7539
I've been trying to introduce
disallow_any_generics = true
to an already extensively typed code base of ~48kSLOC, and the only remaining issue is typingOrderedDict
s.Actual behaviour
Given this configuration:
Code with implicit
Any
:This fails validation because of
disallow_any_generics = true
:Code with typed
OrderedDict
:This passes validation, but doesn't run:
Versions:
(Also failed on mypy 0.711.)
Expected behaviour
I'd expect either the first snippet to be valid or the second snippet to run. As it is I'm stuck for how to proceed.
The text was updated successfully, but these errors were encountered: