From 52e5004b59d89e5f1bf2ceaba0d2c9e63368454b Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Sat, 22 Oct 2016 07:55:18 -0700 Subject: Issue #27989: Tweak inspect.formatannotation() to improve pydoc rendering of function annotations. Ivan L. --- Lib/inspect.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Lib/inspect.py') diff --git a/Lib/inspect.py b/Lib/inspect.py index ca1d551a69..0fd0382776 100644 --- a/Lib/inspect.py +++ b/Lib/inspect.py @@ -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__ -- cgit v1.2.1