Write Union Types as X|Y in Python 3.10

Before Python 3.10, you need to use typing.Union to declare that a variable can have one of several different types.

In Python 3.10, you can replace Union[X, Y] with X | Y to simplify the expression.

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran