[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 
<https://bugs.python.org/issue39990>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue39990] help output should make use of typing.get_type_hints

2020-03-17 Thread Nguyễn Gia Phong

Change by Nguyễn Gia Phong :


--
type:  -> enhancement

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



[issue39990] help output should make use of typing.get_type_hints

2020-03-17 Thread Nguyễn Gia Phong

New submission from Nguyễn Gia Phong :

With PEP 563, it is legal to annotate a function as follows

def foo(bar: 'int') -> 'bool': pass

Currently, help(foo) would print the exact signature in foo.__annotations__ and 
it's not really pretty.  My proposal is to use the type hints from 
typing.get_type_hints to make documentations more readable from the user's 
perspective.  I might not be aware of all use cases and disadvantages of this 
proposal however.

--
assignee: docs@python
components: Documentation
messages: 364399
nosy: McSinyx, docs@python
priority: normal
severity: normal
status: open
title: help output should make use of typing.get_type_hints

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



[issue39125] Type signature of @property not shown in help()

2020-01-02 Thread Nguyễn Gia Phong

Change by Nguyễn Gia Phong :


--
versions: +Python 3.9

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



[issue39125] Type signature of @property not shown in help()

2019-12-30 Thread Nguyễn Gia Phong

Nguyễn Gia Phong  added the comment:

Relating to this, should there also be indication about the mode (get, set, 
del) the property?  Currently there is no way to tell if the *attribute* is 
read-only, read-write or write-only.

--
versions:  -Python 3.9

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



[issue39125] Type signature of @property not shown in help()

2019-12-23 Thread Nguyễn Gia Phong

New submission from Nguyễn Gia Phong :

Dear Maintainer,

I want to request a feature on the generative documentation of type-hinting.
As of December 2019, I believe there is no support for generating such
information in help().  For demonstration, I have this tiny piece of code

class Foo:
@property
def bar(self) -> int: return 42

@bar.setter
def bar(self, value: int) -> None: pass

def baz(self, arg: float) -> str: pass

whose documentation on CPython 3.7.5 (on Debian testing amd64 if that matters)
is generated as

class Foo(builtins.object)
 |  Methods defined here:
 |  
 |  baz(self, arg: float) -> str
 |  
 |  --
 |  Data descriptors defined here:
 |  
 |  __dict__
 |  dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |  list of weak references to the object (if defined)
 |  
 |  bar

I expect the documentation for bar to be as informative as bar, i.e. something
similar to ``bar: int''.  As pointed out by ChrisWarrick on freenode#python,
the annotations are already present, yet help() is not making use of them:

>>> Foo.bar.fget.__annotations__
{'return': }
>>> Foo.bar.fset.__annotations__
{'value': , 'return': None}

Have a Merry Christmas or other holiday of your choice,
Nguyễn Gia Phong

--
assignee: docs@python
components: Documentation
messages: 358823
nosy: McSinyx, docs@python
priority: normal
severity: normal
status: open
title: Type signature of @property not shown in help()
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9

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