@enum.unique class Status(Enum): PENDING = 'pending' APPROVED = 'approved' REJECTED = 'rejected'
Decorators & Metaclasses

Meaning

Defines an enumeration named Status with three string-valued members: PENDING, APPROVED, REJECTED.

Primary Function

Defines a type-safe enumeration of status values for use in code.

Communicative Purpose

Communicates the fixed set of permissible status values for an entity, enabling type-safe comparisons and preventing invalid states.

Função primária

Defines a type-safe enumeration of status values for use in code.

Propósito comunicativo

Communicates the fixed set of permissible status values for an entity, enabling type-safe comparisons and preventing invalid states.

Situações de gatilho

When you need to represent a fixed set of named states (e.g., task status, request status) and want to enforce type safety and avoid magic strings.

Contextos

Used in Python code where a fixed set of string-valued states is needed, such as in models, APIs, workflow engines, or state machines.

Família do chunk

  • enum definition
  • enum.auto
  • IntEnum
  • Flag
  • namedtuple

Upgrade path

Using enum.auto() for automatic values, or IntEnum for integer enums, or Flag for bit flags.

Tag de espaçamento: Long-term

Log in to save chunks.