PEP 604 Union Types
TL;DR
PEP 604 introduced the |
operator for union types, allowing int | str
instead of Union[int, str]
for cleaner type annotations.
Interesting!
The |
operator for union types makes Python’s type hints look more like mathematical set notation - int | str
means “integer OR string”!