1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
# noqa: D100
# stdlib
from enum import IntEnum, IntFlag
from typing import List
# this package
import enum_tools.documentation
__all__ = ["People", "NoMethods", "NoMemberDoc", "StatusFlags"]
enum_tools.documentation.INTERACTIVE = True
@enum_tools.documentation.document_enum
class People(IntEnum):
"""
An enumeration of people.
"""
Bob = bob = 1 # noqa # doc: A person called Bob # doc: another doc # isort: ignore
Alice = 2 # doc: A person called Alice
Carol = 3
"""
A person called Carol.
This is a multiline docstring.
"""
@classmethod
def iter_values(cls): # noqa: MAN002
"""
Iterate over the values of the Enum.
"""
return iter(cls) # pragma: no cover
#: A person called Dennis
Dennis = 4
@classmethod
def as_list(cls) -> List:
"""
Return the Enum's members as a list.
"""
return list(cls) # pragma: no cover
@enum_tools.documentation.document_enum
class NoMethods(IntEnum):
"""
An enumeration of people without any methods.
"""
Bob = bob = 1 # noqa # doc: A person called Bob # doc: another doc # isort: ignore
Alice = 2 # doc: A person called Alice
Carol = 3 # doc: A person called Carol
@enum_tools.documentation.document_enum
class NoMemberDoc(IntEnum):
"""
An enumeration of people without any member docstrings.
"""
Bob = bob = 1
Alice = 2
Carol = 3
@enum_tools.documentation.document_enum
class StatusFlags(IntFlag):
"""
An enumeration of status codes.
"""
Running = 1 # doc: The system is running.
Stopped = 2 # doc: The system has stopped.
Error = 4 # doc: An error has occurred.
def has_errored(self) -> bool: # pragma: no cover
"""
Returns whether the operation has errored.
"""
return (self & 4) == self.Error
|