Issue 26075: typing.Union unifies types too broadly (original) (raw)

from typing import Union, Iterable Union[str, Iterable[int]] typing.Iterable[int]

The union loses the "str" parameter because issubclass(str, collections.abc.Iterable) returns True and the check completely disregards generics.

Guido mentioned that issubclass() support for generic types should be going away. In the mean time, maybe the subclass check in typing.GenericMeta should be modified not to do it with types from Typing, but how can we accurately identify them?