Raymond Hettinger <[email protected]> added the comment:
It looks like the error is in inspect.formatannotation().
For instances of type, that function incorrectly returns only
annotation.__qualname__.
Instead, it should return repr(annotation) which would include the args.
=================================================================
def formatannotation(annotation, base_module=None):
if getattr(annotation, '__module__', None) == 'typing':
return repr(annotation).replace('typing.', '')
if isinstance(annotation, type): # <== Erroneous case
if annotation.__module__ in ('builtins', base_module):
return annotation.__qualname__
return annotation.__module__+'.'+annotation.__qualname__
return repr(annotation)
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue45438>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com