Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created July 2, 2025 00:20
Show Gist options
  • Save mypy-play/eaf416f505bfebbba0c2f9c5c85fa93a to your computer and use it in GitHub Desktop.
Save mypy-play/eaf416f505bfebbba0c2f9c5c85fa93a to your computer and use it in GitHub Desktop.
Shared via mypy Playground
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