Author rhettinger
Recipients gvanrossum, kj, levkivskyi, rhettinger
Date 2021-10-12.21:40:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1634074849.62.0.110656317403.issue45438@roundup.psfhosted.org>
In-reply-to
Content
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)
History
Date User Action Args
2021-10-12 21:40:49rhettingersetrecipients: + rhettinger, gvanrossum, levkivskyi, kj
2021-10-12 21:40:49rhettingersetmessageid: <1634074849.62.0.110656317403.issue45438@roundup.psfhosted.org>
2021-10-12 21:40:49rhettingerlinkissue45438 messages
2021-10-12 21:40:49rhettingercreate