David E. Franco G. added the comment:
as that is the case, how about this as a solution:
def formatannotation(annotation, base_module=None):
if isinstance(annotation, type):
if annotation.__module__ in ('builtins', base_module):
return annotation.__qualname__
elif annotation.__module__ in ('typing', base_module):
return repr(annotation).replace("typing.","")
return annotation.__module__+'.'+annotation.__qualname__
return repr(annotation)
the same way that it check for builtins, do it for typing and clean up a
little.
With that change the result with the example is
>>> help(foo)
Help on function foo in module __main__:
foo(data:List[Any]) -> Iterator[Tuple[int, Any]]
>>>
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27989>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com