From f3d7579aabc542f0ecabedcdb68fcddea2e95ac2 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sun, 8 Nov 2026 03:25:04 +0300 Subject: [PATCH 1/5] gh-161591: sync inspect.signature() docs with actual function signature --- 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 51c465e8f00b5e..06b3248aa62e07 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -853,7 +853,7 @@ and its return annotation. To retrieve a :class:`!Signature` object, use the :func:`!signature` function. -.. function:: signature(callable, *, follow_wrapped=True, globals=None, locals=None, eval_str=False, annotation_format=Format.VALUE) +.. function:: signature(obj, *, follow_wrapped=True, globals=None, locals=None, eval_str=False, annotation_format=Format.VALUE) Return a :class:`Signature` object for the given *callable*: From d749ea3b625797ef54e5d040e9aa4b9af701de78 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sun, 8 Nov 2026 13:30:28 +0300 Subject: [PATCH 2/5] +1 --- Doc/library/inspect.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 06b3248aa62e07..9b72540dd3c48a 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -855,7 +855,7 @@ function. .. function:: signature(obj, *, follow_wrapped=True, globals=None, locals=None, eval_str=False, annotation_format=Format.VALUE) - Return a :class:`Signature` object for the given *callable*: + Return a :class:`Signature` object for the given *obj*: .. doctest:: @@ -904,7 +904,7 @@ function. .. versionchanged:: 3.5 The *follow_wrapped* parameter was added. Pass ``False`` to get a signature of - *callable* specifically (``callable.__wrapped__`` will not be used to + *obj* specifically (``obj.__wrapped__`` will not be used to unwrap decorated callables.) .. versionchanged:: 3.10 From 06c7183de07647ecae1096db9523f182057046a1 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Sun, 8 Nov 2026 14:28:06 +0300 Subject: [PATCH 3/5] Update Doc/library/inspect.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- 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 9b72540dd3c48a..08b6958ac6fb55 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -855,7 +855,7 @@ function. .. function:: signature(obj, *, follow_wrapped=True, globals=None, locals=None, eval_str=False, annotation_format=Format.VALUE) - Return a :class:`Signature` object for the given *obj*: + Return a :class:`Signature` object for the given callable *obj*: .. doctest:: From 569844f058904064ca428e2b8e4eb768a64def5f Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Mon, 9 Nov 2026 02:58:59 +0300 Subject: [PATCH 4/5] +1 --- Doc/library/inspect.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Doc/library/inspect.rst b/Doc/library/inspect.rst index 08b6958ac6fb55..5788fae06adac2 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -371,7 +371,7 @@ attributes (see :ref:`import-mod-attrs` for module attributes): Add ``aga_gen`` attribute to the awaitables returned by the ``asend()``, ``athrow()`` and ``aclose()`` methods of async generators. -.. function:: getmembers(object[, predicate]) +.. function:: getmembers(object, predicate=None) Return all the members of an object in a list of ``(name, value)`` pairs sorted by name. If the optional *predicate* argument—which will be @@ -385,7 +385,7 @@ attributes (see :ref:`import-mod-attrs` for module attributes): listed in the metaclass' custom :meth:`~object.__dir__`. -.. function:: getmembers_static(object[, predicate]) +.. function:: getmembers_static(object, predicate=None) Return all the members of an object in a list of ``(name, value)`` pairs sorted by name without triggering dynamic lookup via the descriptor @@ -487,9 +487,9 @@ attributes (see :ref:`import-mod-attrs` for module attributes): .. versionadded:: 3.14 -.. function:: isgeneratorfunction(object) +.. function:: isgeneratorfunction(obj) - Return ``True`` if the object is a Python generator function. + Return ``True`` if the obj is a Python generator function. It also returns ``True`` for bound methods created from Python generator functions (see :ref:`typesmethods` for more information). @@ -511,9 +511,9 @@ attributes (see :ref:`import-mod-attrs` for module attributes): Return ``True`` if the object is a generator. -.. function:: iscoroutinefunction(object) +.. function:: iscoroutinefunction(obj) - Return ``True`` if the object is a :term:`coroutine function` (a function + Return ``True`` if the obj is a :term:`coroutine function` (a function defined with an :keyword:`async def` syntax), a :func:`functools.partial` wrapping a :term:`coroutine function`, or a sync function marked with :func:`markcoroutinefunction`. @@ -583,9 +583,9 @@ attributes (see :ref:`import-mod-attrs` for module attributes): .. versionadded:: 3.5 -.. function:: isasyncgenfunction(object) +.. function:: isasyncgenfunction(obj) - Return ``True`` if the object is an :term:`asynchronous generator` function, + Return ``True`` if the obj is an :term:`asynchronous generator` function, for example: .. doctest:: @@ -1186,7 +1186,7 @@ function. to ``None`` if their ``kind`` was set to ``POSITIONAL_ONLY``. This is no longer permitted. -.. class:: BoundArguments +.. class:: BoundArguments(signature, arguments) Result of a :meth:`Signature.bind` or :meth:`Signature.bind_partial` call. Holds the mapping of arguments to the function's parameters. @@ -1469,7 +1469,7 @@ Some of the following functions return tuple-like operations on all attributes except ``positions``. This behavior is considered deprecated and may be removed in the future. -.. class:: FrameInfo +.. class:: FrameInfo(frame, filename, lineno, function, code_context, index, *, positions=None) .. attribute:: frame @@ -1512,7 +1512,7 @@ is considered deprecated and may be removed in the future. (that is backwards compatible with the previous :term:`named tuple`). -.. class:: Traceback +.. class:: Traceback(filename, lineno, function, code_context, index, *, positions=None) .. attribute:: filename From 329b4668f325bed36e13f308a638acc865cd088b Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Mon, 9 Nov 2026 11:15:02 +0300 Subject: [PATCH 5/5] Update Doc/library/inspect.rst Co-authored-by: Martin Panter --- 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 5788fae06adac2..75b443a2cb08ba 100644 --- a/Doc/library/inspect.rst +++ b/Doc/library/inspect.rst @@ -489,7 +489,7 @@ attributes (see :ref:`import-mod-attrs` for module attributes): .. function:: isgeneratorfunction(obj) - Return ``True`` if the obj is a Python generator function. + Return ``True`` if *obj* is a Python generator function. It also returns ``True`` for bound methods created from Python generator functions (see :ref:`typesmethods` for more information).