Issue #27989: Tweak inspect.formatannotation() to improve pydoc rendering of function annotations. Ivan L.

This commit is contained in:
Guido van Rossum 2016-10-22 07:55:18 -07:00
parent 1002a621c1
commit 52e5004b59
2 changed files with 15 additions and 0 deletions

View file

@ -1152,6 +1152,8 @@ def getargvalues(frame):
return ArgInfo(args, varargs, varkw, frame.f_locals)
def formatannotation(annotation, base_module=None):
if getattr(annotation, '__module__', None) == 'typing':
return repr(annotation).replace('typing.', '')
if isinstance(annotation, type):
if annotation.__module__ in ('builtins', base_module):
return annotation.__qualname__