pybind / pybind/pybind11

Set the __text_signature__ attribute of callables

Open
#945 24 comments 9 reactions 1 assignee View on GitHub

@YannickJadoul is already working on this.

Since Oct 12, 2020.

Dominant language
C++
Stars
18k
Forks
2.3k
Avg merge
5d 17h
Merged PRs (30d)
10

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.