From cd678d61b61f243b6c80ef57b72f79e5cb56dd05 Mon Sep 17 00:00:00 2001 From: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> Date: Sat, 21 Oct 2023 00:54:02 +0200 Subject: [PATCH] gh-106310 - document the __signature__ attribute (GH-106311) Document the __signature__ attribute (cherry picked from commit b07f23259d30e61fd7cc975b8b0e3b2e846fed8f) Co-authored-by: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> Co-authored-by: Alex Waygood --- Doc/library/inspect.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 22637a051d9fa6..e95196376bb24b 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -619,6 +619,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 @@ -738,6 +741,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