Last active
October 4, 2022 01:26
-
-
Save dogweather/af994d9c8369cad01b8b74465995b9ae to your computer and use it in GitHub Desktop.
This file contains 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
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