[issue29299] Argument Clinic: Fix signature of optional positional-only arguments

Larry Hastings report at bugs.python.org
Fri Mar 15 14:52:19 EDT 2019


Larry Hastings <larry at hastings.org> added the comment:

Argument Clinic can currently only generate signatures for functions whose signatures can be represented in Python.  This is because the signatures are parsed by the inspect module, which in turn uses the ast module to generate a parse tree; it then examines the parse tree and uses that to generate the Signature object.

(By the time you see a signature of a function using inspect, the signature has actually made a round-trip through the ast module, been turned into a Signature object, then str() has been run on it to re-generate the text representation from scratch.  The fact that it's usually identical to the original text signature buried in the function's docstring is a happy accident.)

Changing Argument Clinic to generate signatures with square brackets in them to signify optional parameters is insufficient.  You'd also have to upgrade inspect to support this new syntax--otherwise there'd be no point.  And *that* would be a lot of code.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue29299>
_______________________________________


More information about the Python-bugs-list mailing list