[New-bugs-announce] [issue39125] Type signature of @property not shown in help()
Nguyễn Gia Phong
report at bugs.python.org
Mon Dec 23 10:40:00 EST 2019
New submission from Nguyễn Gia Phong <vn.mcsinyx at gmail.com>:
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': <class 'int'>}
>>> Foo.bar.fset.__annotations__
{'value': <class 'int'>, 'return': None}
Have a Merry Christmas or other holiday of your choice,
Nguyễn Gia Phong
----------
assignee: docs at python
components: Documentation
messages: 358823
nosy: McSinyx, docs at 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 <report at bugs.python.org>
<https://bugs.python.org/issue39125>
_______________________________________
More information about the New-bugs-announce
mailing list