[issue27989] incomplete signature with help function using typing
David E. Franco G.
report at bugs.python.org
Wed Sep 7 10:18:47 EDT 2016
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 <report at bugs.python.org>
<http://bugs.python.org/issue27989>
_______________________________________
More information about the Python-bugs-list
mailing list