Write Union Types with X|Y

Write Union Types with X|Y

typing.Union[X, Y] is used to declare that a variable can be either X or Y. In Python 3.10 and above, you can replace Union[X, Y] with X|Y.

My previous tips on typing.

Search

Scroll to Top

Work with Khuyen Tran

Work with Khuyen Tran