Skip to content

Instantly share code, notes, and snippets.

@dogweather
Last active October 4, 2022 01:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
from enum import Enum
from typing import NoReturn
class Color(Enum):
RED = "RED"
GREEN = "GREEN"
BLUE = "BLUE" # I just added this
def handle_color(color: Color) -> None:
if color is Color.RED:
...
elif color is Color.GREEN:
...
else:
assert_never(color)
def assert_never(value: NoReturn) -> NoReturn:
assert False, f"Unknown value: {value}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment