[issue39990] help should evaluate forward reference

2020-05-02 Thread Filipe Laíns

Change by Filipe Laíns :


--
keywords: +patch
pull_requests: +19185
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/19874

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39990] help should evaluate forward reference

2020-05-02 Thread Filipe Laíns

Filipe Laíns  added the comment:

typing.get_type_hints can be used for this, it resolves the annotation string.

>>> def foo(bar: 'int') -> 'bool': pass
...
>>> typing.get_type_hints(foo)
{'bar': , 'return': }

--
nosy: +FFY00

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39990] help should evaluate forward reference

2020-03-17 Thread Nguyễn Gia Phong

Nguyễn Gia Phong  added the comment:

I traced it down to inspect.formatannotation(annotation).  Before checking for 
isinstance(annotation, type), IMHO we should do something like

import typing

if isinstance(annotation, str):
annotation = typing.ForwardRef(str)._evaluate(annotation)

However, is is not aware of globals and especially locals of help caller, so I 
guess more sophisticated solution is required.

--
title: help output should make use of typing.get_type_hints -> help should 
evaluate forward reference

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com