enums_members
error
Enum member annotated with an explicit type
In an Enum class, members should NOT carry explicit type annotations. If an attribute inside an Enum class body has both a type annotation and an assigned value, it is treated as an annotated member — which is an error because the type checker infers a LiteralEnumClass.member type for all members automatically.
A type annotation without an assigned value (e.g. genus: str) is a **non-member attribute** and is valid.
from enum import Enum
class Pet(Enum):
genus: str # OK — non-member attribute (annotation only, no value)
CAT = "felis" # OK — member without annotation
DOG: int = 2 # E — member with explicit type annotation
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
enums_members down per-file or per-path from your editor or
pyproject.toml, or fix the code
so it type-checks. See the Type System rules and
the complete diagnostic reference.
Canonical URL: https://www.basilisk-python.dev/errors/enums_members