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.
typing.Union[X, Y]
X
Y
Union[X, Y]
X|Y
My previous tips on typing.