Skip to content

Instantly share code, notes, and snippets.

@mypy-play
Created June 4, 2025 14:09
Show Gist options
  • Save mypy-play/b1af4c5dd963eecfaa62b8fb6034420a to your computer and use it in GitHub Desktop.
Save mypy-play/b1af4c5dd963eecfaa62b8fb6034420a to your computer and use it in GitHub Desktop.
Shared via mypy Playground
from enum import Enum
class Foo(Enum):
A = 0
B = 0
def bar(foo: Foo) -> None:
if foo is Foo.A:
...
elif foo is Foo.B:
...
else:
# some long other logic for whatever reason.
# should be marked as unreachable
message = "unknown Foo"
raise ValueError(message, foo)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment