from typing import Union
print(isinstance(1, Union[str, int])) # error: Argument 2 to "isinstance" has incompatible type "object"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]"
But this outputs True
Union[X, Y] is stubbed to return object when it really returns a typing._UnionGenericAlias to typing.Union so that would need to be fixed first.
playground