Skip to content

Spurious error about _ignore_ in subclass of enum #12121

Closed
@kstauffer

Description

@kstauffer

mypy has a false positive here:

from enum import Enum
class E(Enum):
    _ignore_ = ""  # mypy error: Cannot override writable attribute "_ignore_" with a final one  [misc]

Is this actually a typeshed problem? enum.pyi has _ignore_: str | list[str]. Should that be Final? Or, would that be papering over the problem since _ignore_ doesn't actually exist after the metaclass processes the class body?

Your Environment

WSL Ubuntu 20.04
python 3.8.10
mypy 0.931

No flags or config file.

Workaround (type:ignore[misc]) is easy enough for now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions