]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-154320: Fix swapped __defaults__/__kwdefaults__ in annotationlib docs (#154321)
authorSolaris-star <67425364+Solaris-star@users.noreply.github.com>
Tue, 21 Jul 2026 12:45:42 +0000 (20:45 +0800)
committerGitHub <noreply@github.com>
Tue, 21 Jul 2026 12:45:42 +0000 (12:45 +0000)
The bullet list under "Creating a custom callable annotate function"
had the attribute names reversed: positional defaults are __defaults__
(a tuple) and keyword defaults are __kwdefaults__ (a dict). The example
code below was already correct.

Fixes #154320

Doc/library/annotationlib.rst

index af28fe0e2fde2f83268c27d8a8ac1e3fc1571c7d..a90754620b59fdf937883b121d09113e4369def5 100644 (file)
@@ -535,9 +535,9 @@ following attributes:
   :attr:`~Format.VALUE_WITH_FAKE_GLOBALS`.
 * A :ref:`code object <code-objects>` ``__code__`` containing the compiled code for the
   annotate function.
-* Optional: A tuple of the function's positional defaults ``__kwdefaults__``, if the
+* Optional: A tuple of the function's positional defaults ``__defaults__``, if the
   function represented by ``__code__`` uses any positional defaults.
-* Optional: A dict of the function's keyword defaults ``__defaults__``, if the function
+* Optional: A dict of the function's keyword defaults ``__kwdefaults__``, if the function
   represented by ``__code__`` uses any keyword defaults.
 * Optional: All other :ref:`function attributes <inspect-types>`.