I am getting a MyPy error "Missing return statement", even when I check for all possible cases inside a function.
For example, in the following code, MyPy is still giving me an error "9: error: Missing return statement"
, even though color
can only be Color.RED
, Color.GREEN
, or Color.BLUE
, and I test all those cases!
class Color(enum.IntEnum):RED: int = 1GREEN: int = 2BLUE: int = 3def test_enum(color: Color) -> str:if color == Color.RED:return "red"elif color == Color.GREEN:return "green"elif color == Color.BLUE:return "blue"