Skip to content

Re-document __signature__ as a feature #116124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions Doc/library/inspect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,16 @@ function.
Accepts a wide range of Python callables, from plain functions and classes to
:func:`functools.partial` objects.

If the passed object has a :attr:`!__signature__` attribute containing
an instance of :class:`Signature`, this function returns it.
If the attribute contains None, it is ignored.

.. impl-detail::

The behavior when the :attr:`!__signature__` attribute contains a value of
any other type is an implementation detail and subject to
unannounced changes. Consult the source code for current semantics.

For objects defined in modules using stringized annotations
(``from __future__ import annotations``), :func:`signature` will
attempt to automatically un-stringize the annotations using
Expand Down Expand Up @@ -699,13 +709,6 @@ function.
Python. For example, in CPython, some built-in functions defined in
C provide no metadata about their arguments.

.. impl-detail::

If the passed object has a :attr:`!__signature__` attribute,
we may use it to create the signature.
The exact semantics are an implementation detail and are subject to
unannounced changes. Consult the source code for current semantics.


.. class:: Signature(parameters=None, *, return_annotation=Signature.empty)

Expand Down