from typing import Literal, assert_never def area(shape: Literal['sq', 'tr'], v: float) -> float: match shape: case 'sq': return v * v case 'tr': return v * v / 2 case _: assert_never(shape) print(area('sq', 3))