Back to Intellij Community

PyEnumInspection

python/python-psi-impl/resources/inspectionDescriptions/PyEnumInspection.html

2025.3-rc-2562 B
Original Source

Reports invalid definition and usage of Enum.

Example:

from enum import Enum

class Shape(Enum):
    SQUARE = 1
    CIRCLE = 2

class ExtendedShape(Shape): # Enum class 'Shape' is final and cannot be subclassed
    TRIANGLE = 3
from enum import Enum

class Color(Enum):
    _value_: int
    RED = 1
    GREEN = "green" # Type 'str' is not assignable to declared type 'int'
from enum import Enum

class Pet(Enum):
    CAT = 1
    DOG: int = 2 # Type annotations are not allowed for enum members