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

reversed(Enum) #3349

Closed
MeGotsThis opened this issue May 10, 2017 · 4 comments
Closed

reversed(Enum) #3349

MeGotsThis opened this issue May 10, 2017 · 4 comments

Comments

@MeGotsThis
Copy link

As a semi-continuation of #2891, using mypy 0.510.

import enum

class Letters(enum.Enum):
    A = 0
    B = 1

l: Letters

for l in Letters:
    print(l)
for l in reversed(Letters):
    print(l)

Running mypy gives this error

enum-test.py:11: error: Incompatible types in assignment (expression has type "Enum", variable has type "Letters")

Line 11 is the 2nd for loop.

@elazarg
Copy link
Contributor

elazarg commented May 10, 2017

Is it not precisely #3210 ?

@ilevkivskyi
Copy link
Member

It looks very similar, but I propose to keep this open, so that we will not forget to add this example to tests when fixing #3210.

@gvanrossum
Copy link
Member

Explain to me again why this is not a duplicate of #3210? If we want to remember to add both examples to the tests we can just add this example to #3210. E.g.

from enum import Enum

class E(Enum):
    one = 1

reveal_type(list(E))  # 'builtins.list[enum.Enum*]'

reveal_type(reversed(E))  # 'typing.Iterator[enum.Enum*]'

@ilevkivskyi
Copy link
Member

All examples in this issue now work correctly on mypy master.

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

4 participants