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

This commit is contained in:
Guido van Rossum 2016-10-22 07:56:58 -07:00
commit 265dce6cbb
2 changed files with 15 additions and 0 deletions

View file

@ -1140,6 +1140,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__