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

IntEnum "is not indexable" #4941

Closed
alexmv opened this issue Apr 19, 2018 · 3 comments
Closed

IntEnum "is not indexable" #4941

alexmv opened this issue Apr 19, 2018 · 3 comments
Labels
bug mypy got something wrong priority-1-normal

Comments

@alexmv
Copy link

alexmv commented Apr 19, 2018

from enum import IntEnum
Color = IntEnum('Color', 'red green blue')
Color['green']

...yields:

test.py:3: error: Value of type "Type[Color]" is not indexable

This example is more or less straight out of the enum docs -- my expectation is that it should not be a type error.

Mypy version 025e3de

@ilevkivskyi
Copy link
Member

Note that this problem is absent for a simple Enum. Also IntEnum fails the following code:

for c in Color:  # E: not iterable
    reveal_type(c)

I thought this should be fixed by #4319 @elazarg what do you think?

@ilevkivskyi ilevkivskyi added bug mypy got something wrong priority-1-normal labels Apr 19, 2018
@elazarg
Copy link
Contributor

elazarg commented Apr 19, 2018

It only happens for functional api of non-Enum enums. I will look into it.

@aalvrz
Copy link

aalvrz commented Jul 28, 2021

I am experiencing this with mypy==0.780, with similar errors:

"IntEnum" not callable
"IntEnum" is not indexable

When doing:

val = self.enum_class(value)
val = self.enum_class[value.upper()]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong priority-1-normal
Projects
None yet
Development

No branches or pull requests

4 participants