You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support indexing and iterating Enum type objects #741
I'm not sure this is completely fixed: Color['red'] works, but val = Color['red'] results in the old error.
Adding an explicit annotation (val : Color = Color['red']) fixes the error and is an easy workaround, so whatever remains here is probably a lower priority to fix.
Activity
johnthagen commentedon Aug 27, 2016
@JukkaL Another related
Enumissue is that Mypy currently doesn't understand thatEnum's can be iterated on.When run:
When
mypy0.4.4 is run on the file:gvanrossum commentedon Oct 24, 2016
See also #2305.
choucavalier commentedon Jan 20, 2017
Is someone working on this?
gvanrossum commentedon Jan 20, 2017
Not yet.
JukkaL commentedon Apr 4, 2017
Increasing priority since this seems to be among the most common issues mypy users encounter.
ilevkivskyi commentedon Apr 4, 2017
I just have tried
Color['red']and it works. The second snippet:still fails however.
JukkaL commentedon Apr 4, 2017
Yes, I just noticed that myself.
[-]Support indexing Enum type objects[/-][+]Support indexing and iterating Enum type objects[/+]gvanrossum commentedon Apr 4, 2017
Iterating is now fix by python/typeshed#1136.
choucavalier commentedon Apr 4, 2017
Thanks @gvanrossum! 😄
jboning commentedon Apr 5, 2017
I'm not sure this is completely fixed:
Color['red']works, butval = Color['red']results in the old error.Adding an explicit annotation (
val : Color = Color['red']) fixes the error and is an easy workaround, so whatever remains here is probably a lower priority to fix.JelleZijlstra commentedon Apr 5, 2017
From the discussion on Gitter, it seems that
val = Color['red']is interpreted as constructing a type alias.gvanrossum commentedon Apr 6, 2017
Could you file a new issue?
jboning commentedon Apr 6, 2017
Forked off another issue at #3137