Skip to content

Mypy doesn't recognize metaclass implementing __getitem__ #1771

@sangsta

Description

@sangsta

Suppose we have an Enum called MyEnum, and we try something like MyEnum["foo"], mypy will give us an error Value of type "MyEnum" is not indexable. We believe this is because mypy has trouble recognizing when a metaclass implements __getitem__.

A workaround is to do getattr(MyEnum, "foo"), but it'd be nice to have an actual fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions