From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 23 Oct 2023 15:49:17 +0000 (+0200) Subject: [3.11] gh-106310 - document the __signature__ attribute (GH-106311) (#111146) X-Git-Tag: v3.11.7~142 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=135d5c58405fd4b4d6310206f2b63e3da7b1e69c;p=thirdparty%2FPython%2Fcpython.git [3.11] gh-106310 - document the __signature__ attribute (GH-106311) (#111146) Co-authored-by: Gouvernathor <44340603+Gouvernathor@users.noreply.github.com> Co-authored-by: Alex Waygood --- diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 22637a051d9f..e95196376bb2 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