This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author David E. Franco G.
Recipients David E. Franco G., Spencer Brown, gvanrossum
Date 2016-09-07.14:18:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473257927.13.0.313458686726.issue27989@psf.upfronthosting.co.za>
In-reply-to
Content
as that is the case, how about this as a solution:

def formatannotation(annotation, base_module=None):
    if isinstance(annotation, type):
        if annotation.__module__ in ('builtins', base_module):
            return annotation.__qualname__
        elif annotation.__module__ in ('typing', base_module):       
            return repr(annotation).replace("typing.","")
        return annotation.__module__+'.'+annotation.__qualname__
    return repr(annotation)

the same way that it check for builtins, do it for typing and clean up a little. 

With that change the result with the example is

>>> help(foo)
Help on function foo in module __main__:

foo(data:List[Any]) -> Iterator[Tuple[int, Any]]

>>>
History
Date User Action Args
2016-09-07 14:18:47David E. Franco G.setrecipients: + David E. Franco G., gvanrossum, Spencer Brown
2016-09-07 14:18:47David E. Franco G.setmessageid: <1473257927.13.0.313458686726.issue27989@psf.upfronthosting.co.za>
2016-09-07 14:18:47David E. Franco G.linkissue27989 messages
2016-09-07 14:18:47David E. Franco G.create