Skip to content

Set the __text_signature__ attribute of callables #945

@anntzer

Description

@anntzer

Issue description

On recent enough Python versions (I think 3.4+), non-overloaded Python functions created by pybind11 could set the __text_signature__ attribute to a textual representation of the function signature, instead of prepending it to the docstring (see inspect._signature_from_builtin in the stdlib). This attribute is recognized (and parsed) by at least pydoc and inspect.signature (and thus, I guess, Sphinx too, though I am not sure), so it would perform the task of communicating the function signature better than the current method.

(Originally posted on gitter, it was suggested that I put the proposal here.)

Reproducible example code

N/A

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions