[New-bugs-announce] [issue25390] Can't define a typing.Union containing a typing.re.Pattern
Martí Congost Tapias
report at bugs.python.org
Tue Oct 13 11:27:47 CEST 2015
New submission from Martí Congost Tapias:
Defining a union of typing.re.Pattern and anything that isn't AnyStr raises a TypeError exception.
Example:
from typing import Union, re
def foo(pattern: Union[str, re.Pattern]) -> None:
pass
Exception traceback:
Traceback (most recent call last):
File "/tmp/testtyping.py", line 7, in <module>
def foo(pattern: Union[str, re.Pattern]) -> None:
File "/usr/local/lib/python3.5/typing.py", line 534, in __getitem__
dict(self.__dict__), parameters, _root=True)
File "/usr/local/lib/python3.5/typing.py", line 491, in __new__
for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
File "/usr/local/lib/python3.5/typing.py", line 491, in <genexpr>
for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
TypeError: issubclass() arg 1 must be a class
----------
components: Interpreter Core
messages: 252923
nosy: Martí Congost Tapias
priority: normal
severity: normal
status: open
title: Can't define a typing.Union containing a typing.re.Pattern
type: behavior
versions: Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25390>
_______________________________________
More information about the New-bugs-announce
mailing list