Created
June 24, 2025 15:08
-
-
Save mypy-play/18540009e25f31525cd1b872ca2a252c to your computer and use it in GitHub Desktop.
Shared via mypy Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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