Closed
Description
Bug report
Source:
Lines 1449 to 1458 in 91afe66
An error replacement happens in:
repr(annotation).replace('typing.', '')
Suppose that I define a class or Protocol under foo/typing.py
:
class A:
pass
Then Union[int, A]
will turn to Union[int, foo.A]
, but expected result is Union[int, foo.typing.A]
Any module with suffix like xxtyping
will be replaced, such as nptyping
.
Solution
Replace the line to:
def repl(match):
text = match.group()
if text.startswith('typing.'):
return text[len('typing.'):]
return text
return re.sub(r'[\w\.]+', repl, repr(annotation))