mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
Issue #27989: Tweak inspect.formatannotation() to improve pydoc rendering of function annotations. Ivan L. (3.5->3.6)
This commit is contained in:
commit
265dce6cbb
2 changed files with 15 additions and 0 deletions
|
@ -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__
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue