from typing import Literal def f(x: int) -> None: if x == 1 or x == 2: _: Literal[1, 2] = x