Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created June 24, 2025 15:08
Show Gist options
  • Save mypy-play/18540009e25f31525cd1b872ca2a252c to your computer and use it in GitHub Desktop.
Save mypy-play/18540009e25f31525cd1b872ca2a252c to your computer and use it in GitHub Desktop.
Shared via mypy Playground
import enum
import typing
class Simple(enum.IntEnum):
OPTION = ...
class WithValue(enum.IntEnum):
_value_: int
OPTION = ...
class WithDirectValue(enum.IntEnum):
_value_: int
OPTION = 2
class NonInt(enum.Enum):
_value_: str
OPTION = "str"
typing.reveal_type(Simple.OPTION)
typing.reveal_type(Simple.OPTION.value)
typing.reveal_type(WithValue.OPTION)
typing.reveal_type(WithValue.OPTION.value)
typing.reveal_type(WithDirectValue.OPTION)
typing.reveal_type(WithDirectValue.OPTION.value)
typing.reveal_type(NonInt.OPTION)
typing.reveal_type(NonInt.OPTION.value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment