Convert text or a value into an enumerated type, if possible. *value*, the ``int`` or ``str`` to convert. Raises a class-specific exception if a ``str`` is provided that cannot be converted. Raises ``ValueError`` if the value is out of range. Returns an en
(cls: Type[TIntEnum], value: int | str)
| 70 | |
| 71 | @classmethod |
| 72 | def make(cls: Type[TIntEnum], value: int | str) -> TIntEnum: |
| 73 | """Convert text or a value into an enumerated type, if possible. |
| 74 | |
| 75 | *value*, the ``int`` or ``str`` to convert. |
| 76 | |
| 77 | Raises a class-specific exception if a ``str`` is provided that |
| 78 | cannot be converted. |
| 79 | |
| 80 | Raises ``ValueError`` if the value is out of range. |
| 81 | |
| 82 | Returns an enumeration from the calling class corresponding to the |
| 83 | value, if one is defined, or an ``int`` otherwise. |
| 84 | """ |
| 85 | |
| 86 | if isinstance(value, str): |
| 87 | return cls.from_text(value) |
| 88 | cls._check_value(value) |
| 89 | return cls(value) |
| 90 | |
| 91 | @classmethod |
| 92 | def _maximum(cls): |