Skip to content

Support indexing and iterating Enum type objects #741

Closed
@JukkaL

Description

@JukkaL

Assume this definition of Color:

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

Now this should be valid, but mypy complains about it:

Color['red']

The error message indicates that mypy thinks that the programmer is trying to construct a generic type, which is not the case here:

$ mypy t.py
t.py:8: error: Name 'red' is not defined

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions