Either this or that type for Python before 3.10



examples/python-types-at-pyweb-2025-01/union.py
from typing import Union

def my_exit(code: Union[str, int]):
    print(type(code).__name__)

my_exit(3)
my_exit("problem")
my_exit(3.14)

$ python union.py
int
str
float

$ mypy union.py
union.py:8:9: error: Argument 1 to "my_exit" has incompatible type "float"; expected "str | int"  [arg-type]
Found 1 error in 1 file (checked 1 source file)