Skip to content

PY-ENUM0001 · redundant_enum_value

Detect explicit enum values that standard auto() would preserve.

This is a deterministic rule for python. Read its implementation.

Inspect direct subclasses of Enum, IntEnum, StrEnum, Flag, and IntFlag. A literal is redundant when it equals the next value generated by the standard enum implementation. Classes that override _generate_next_value_ are excluded. String values in a plain Enum remain explicit because its auto() value is an increasing integer.

Every finding identifies one assignment whose runtime value is preserved by auto().

Keep explicit protocol values, aliases, compatibility values, mixed value types, custom generation, and spelling whose public meaning differs from the member name.

FAST = "fast" in a StrEnum, FIRST = 1 in an Enum, and READ = 1 in a Flag are replaceable by auto(). HTTP_OK = 200 and PUBLIC = "public-name" remain explicit.

  • Cites “The Python Standard Library”, enum documentation for auto and _generate_next_value_