[New-bugs-announce] [issue31939] Support return annotation in signature for Argument Clinic
STINNER Victor
report at bugs.python.org
Fri Nov 3 19:31:32 EDT 2017
New submission from STINNER Victor <victor.stinner at gmail.com>:
Argument Clinic supports a few return types like NoneType, int, bool, etc. But the return type is omitted in the private docstring used to build the __text_signature__, finally used to build a Signature object in inspect.signature().
For example, os.dup() is declared in Modules/posixmodule.c with:
/*[clinic input]
os.dup -> int
fd: int
/
Return a duplicate of a file descriptor.
[clinic start generated code]*/
Currently, Argument Clinic generates:
PyDoc_STRVAR(os_dup__doc__,
"dup($module, fd, /)\n"
"--\n"
"\n"
"Return a duplicate of a file descriptor.");
The return type is omitted in the first line.
Finally, the return type is not documented in the signature:
haypo at selma$ ./python -c "import os,inspect; print(inspect.signature(os.dup))"
(fd, /)
I noticed this limitation while reviewing the PR 4265 which converts the select module to Argument Clinic. Previously, the return type like "-> None" or "-> int" was documented. With Argument Clinic, it's not documented nor generated in the signature, the information is lost.
----------
messages: 305525
nosy: brett.cannon, haypo, larry, ncoghlan, serhiy.storchaka, yselivanov
priority: normal
severity: normal
status: open
title: Support return annotation in signature for Argument Clinic
type: enhancement
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31939>
_______________________________________
More information about the New-bugs-announce
mailing list