]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106310 - document the __signature__ attribute (#106311)
authorGouvernathor <44340603+Gouvernathor@users.noreply.github.com>
Fri, 20 Oct 2023 22:54:02 +0000 (00:54 +0200)
committerGitHub <noreply@github.com>
Fri, 20 Oct 2023 22:54:02 +0000 (08:54 +1000)
Document the __signature__ attribute

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Doc/library/inspect.rst

index 3efd3be59092546ac7c9fda5a3c900fea3cb5708..b463c0b6d0e4020e16eaa328320d95676b33cb16 100644 (file)
@@ -640,6 +640,9 @@ function.
    Accepts a wide range of Python callables, from plain functions and classes to
    :func:`functools.partial` objects.
 
+   If the passed object has a ``__signature__`` attribute, this function
+   returns it without further computations.
+
    For objects defined in modules using stringized annotations
    (``from __future__ import annotations``), :func:`signature` will
    attempt to automatically un-stringize the annotations using
@@ -763,6 +766,8 @@ function.
          sig = MySignature.from_callable(min)
          assert isinstance(sig, MySignature)
 
+       Its behavior is otherwise identical to that of :func:`signature`.
+
        .. versionadded:: 3.5
 
        .. versionadded:: 3.10