-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
mypy interprets variable as a type during Enum indexing #1381
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
Labels
Comments
PEP 435 enums allow indexing the class to dynamically look up an enum. E.g.
`Color['green']` is the same as`Color.green`.
If the class is not generic mypy shouldn't flag it as an error.
|
Different kind of error is reported when more complex indexing argument is passed:
Error: |
I think maybe this also ought to be given higher priority. |
FWIW I am going special-case enums here, rather than change the behavior for all non-generic classes. (Generic enums make no sense, but we don't currently detect this.) |
gvanrossum
pushed a commit
that referenced
this issue
Feb 6, 2017
JukkaL
pushed a commit
that referenced
this issue
Feb 7, 2017
* Allow E[<str>] where E is an Enum type. Fixes #1381. * Respond to review by @ilevkivskyi
gvanrossum
pushed a commit
that referenced
this issue
Feb 12, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example code, where
row.status
is expected to be a string:Error:
In a similar case, I also received this error in addition to the above:
error: Generic type not valid as an expression any more (use '# type:' comment instead)
The text was updated successfully, but these errors were encountered: