enums

 1import enum
 2
 3
 4class EnumDemo(enum.Enum):
 5    """
 6    This is an example of an Enum.
 7
 8    As usual, you can link to individual properties: `GREEN`.
 9    """
10
11    RED = 1
12    """I am the red."""
13    GREEN = 2
14    """I am green."""
15    BLUE = enum.auto()
16
17
18class EnumWithoutDocstrings(enum.Enum):
19    FOO = enum.auto()
20    BAR = enum.auto()
21
22
23class IntEnum(enum.IntEnum):
24    FOO = enum.auto()
25    BAR = enum.auto()
26
27
28class StrEnum(enum.StrEnum):
29    FOO = enum.auto()
30    BAR = enum.auto()
31
32    def isprintable(self) -> bool:
33        """This method has different docstrings depending on the Python version, so we override here for testing purposes."""
34        raise NotImplementedError
class EnumDemo(enum.Enum):
 5class EnumDemo(enum.Enum):
 6    """
 7    This is an example of an Enum.
 8
 9    As usual, you can link to individual properties: `GREEN`.
10    """
11
12    RED = 1
13    """I am the red."""
14    GREEN = 2
15    """I am green."""
16    BLUE = enum.auto()

This is an example of an Enum.

As usual, you can link to individual properties: GREEN.

RED = <EnumDemo.RED: 1>

I am the red.

GREEN = <EnumDemo.GREEN: 2>

I am green.

BLUE = <EnumDemo.BLUE: 3>
class EnumWithoutDocstrings(enum.Enum):
19class EnumWithoutDocstrings(enum.Enum):
20    FOO = enum.auto()
21    BAR = enum.auto()
class IntEnum(enum.IntEnum):
24class IntEnum(enum.IntEnum):
25    FOO = enum.auto()
26    BAR = enum.auto()
FOO = <IntEnum.FOO: 1>
BAR = <IntEnum.BAR: 2>
class StrEnum(enum.StrEnum):
29class StrEnum(enum.StrEnum):
30    FOO = enum.auto()
31    BAR = enum.auto()
32
33    def isprintable(self) -> bool:
34        """This method has different docstrings depending on the Python version, so we override here for testing purposes."""
35        raise NotImplementedError
FOO = <StrEnum.FOO: 'foo'>
BAR = <StrEnum.BAR: 'bar'>
def isprintable(self) -> bool:
33    def isprintable(self) -> bool:
34        """This method has different docstrings depending on the Python version, so we override here for testing purposes."""
35        raise NotImplementedError

This method has different docstrings depending on the Python version, so we override here for testing purposes.