Created
July 2, 2025 00:20
-
-
Save mypy-play/eaf416f505bfebbba0c2f9c5c85fa93a 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 functools | |
import typing as t | |
class Color(enum.Enum): | |
RED = enum.auto() | |
@enum.nonmember | |
@functools.cache | |
def lowercase_name(self) -> str: | |
return self.name.lower() | |
t.assert_type(Color.RED.value, int) # works | |
def frobnicate(color: Color) -> None: | |
t.assert_type(color.value, int) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment