While running the previous test case I've included in #5, I also came across problems in PyCharm where the builtin issubclass is called with arguments type_ and typing.Union (e.g. L#457, L#475, etc.). By the following example, and the source in the standard library, you cannot call issubclass on typing.Union, since it can't be subclassed.
>>> from typing import Union
>>> issubclass(str, Union[str])
True
>>> issubclass(str, Union[str, float])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/typing.py", line 770, in __subclasscheck__
raise TypeError("Unions cannot be used with issubclass().")
TypeError: Unions cannot be used with issubclass().
The former only works because the constructor of typing.Union returns the single type (c.f. this comment in the docstring, and this if-statement in the __new__ block).
While running the previous test case I've included in #5, I also came across problems in PyCharm where the builtin
issubclassis called with argumentstype_andtyping.Union(e.g. L#457, L#475, etc.). By the following example, and the source in the standard library, you cannot callissubclassontyping.Union, since it can't be subclassed.The former only works because the constructor of
typing.Unionreturns the single type (c.f. this comment in the docstring, and thisif-statement in the__new__block).