[New-bugs-announce] [issue26075] typing.Union unifies types too broadly

Alex Grönholm report at bugs.python.org
Sun Jan 10 07:57:34 EST 2016


New submission from Alex Grönholm:

>>> 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?

----------
components: Extension Modules
messages: 257910
nosy: alex.gronholm, gvanrossum, lukasz.langa
priority: normal
severity: normal
status: open
title: typing.Union unifies types too broadly
type: behavior
versions: Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26075>
_______________________________________


More information about the New-bugs-announce mailing list