Skip to content
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

Indexing Enum type objects fails sometimes #3137

Closed
jboning opened this issue Apr 6, 2017 · 1 comment · Fixed by #3140
Closed

Indexing Enum type objects fails sometimes #3137

jboning opened this issue Apr 6, 2017 · 1 comment · Fixed by #3140
Labels
bug mypy got something wrong

Comments

@jboning
Copy link
Contributor

jboning commented Apr 6, 2017

Assume this definition of Color:

from enum import Enum
class Color(Enum):
    red = 1
    green = 2
    blue = 3

Color['red'] works, and 'val : Color = Color['red']both work, butval = Color['red']` does not work:

error: Name 'red' is not defined
error: "Color" expects no type arguments, but 1 given

Reference #741

@gvanrossum
Copy link
Member

Whoops, yes, definitely a bug. Not sure yet how to fix it.

@gvanrossum gvanrossum added the bug mypy got something wrong label Apr 7, 2017
JelleZijlstra added a commit to JelleZijlstra/mypy that referenced this issue Apr 7, 2017
ilevkivskyi pushed a commit that referenced this issue Apr 7, 2017
* disallow generic Enums and fix assigning Enum indexes

Fixes #3137

* add "x = E[1]" test
@ilevkivskyi ilevkivskyi marked this as a duplicate of #3781 Jul 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants