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

MyPy flags iterating over an enum as an error #978

Closed
gkoller opened this issue Mar 9, 2017 · 1 comment
Closed

MyPy flags iterating over an enum as an error #978

gkoller opened this issue Mar 9, 2017 · 1 comment

Comments

@gkoller
Copy link

gkoller commented Mar 9, 2017

Using Python 3.4 with the typing module (v3.5.3.0) from PyPi and MyPy (v0.501), the following code:

from enum import Enum

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

for color in Color:
    print(color)

triggers MyPy to report the following errors:

iter_enum.py:8: error: Iterable expected
iter_enum.py:8: error: "Color" has no attribute "__iter__"

That seems incorrect as the script runs without errors producing the following output:

Color.red
Color.green
Color.blue
@gkoller
Copy link
Author

gkoller commented Mar 9, 2017

I'm sorry. Wrong project. And it has already been solved in MyPy. See: python/mypy#2305

@gkoller gkoller closed this as completed Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant