From 72823f5517c94ec924440c4df24b677fd125444c Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 29 Feb 2024 00:33:04 +0100 Subject: [PATCH 1/4] gh-115937: Remove implementation details from inspect.signature() docs Co-authored-by: Carol Willing Co-authored-by: Gregory P. Smith Co-authored-by: Jelle Zijlstra --- Doc/library/inspect.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 8a74cadb98a0db..e75871ede16789 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -665,9 +665,6 @@ 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 @@ -702,6 +699,12 @@ function. Python. For example, in CPython, some built-in functions defined in C provide no metadata about their arguments. + .. note:: + + We may use the :attr:`!__signature__` attribute 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) From 15a5e30141b536621a9f5b0d1a4215fb9636ba4e Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 29 Feb 2024 00:46:46 +0100 Subject: [PATCH 2/4] Update Doc/library/inspect.rst Co-authored-by: Jelle Zijlstra --- Doc/library/inspect.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index e75871ede16789..65ab97acfb21b1 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -701,7 +701,7 @@ function. .. note:: - We may use the :attr:`!__signature__` attribute to create the signature. + 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. From 8fb6a117a3bf8d263f92db18cbd727788266a686 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 29 Feb 2024 00:47:15 +0100 Subject: [PATCH 3/4] Reflow --- Doc/library/inspect.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 65ab97acfb21b1..41864fcc6782cf 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -701,7 +701,8 @@ function. .. note:: - If the passed object has a :attr:`!__signature__` attribute, we may use it to create the signature. + 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. From c1dec412ce9262d1a42f1d36086d8dd6e58d8974 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 29 Feb 2024 10:36:18 +0100 Subject: [PATCH 4/4] Update Doc/library/inspect.rst --- Doc/library/inspect.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 41864fcc6782cf..ed8d705da3b0b5 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -699,7 +699,7 @@ function. Python. For example, in CPython, some built-in functions defined in C provide no metadata about their arguments. - .. note:: + .. impl-detail:: If the passed object has a :attr:`!__signature__` attribute, we may use it to create the signature.