]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-143886: Ensure function annotations are returned in order of definition (#143888)
authorCarey Metcalfe <carey@cmetcalfe.ca>
Wed, 15 Apr 2026 13:24:28 +0000 (09:24 -0400)
committerGitHub <noreply@github.com>
Wed, 15 Apr 2026 13:24:28 +0000 (06:24 -0700)
commitcb339d3c9eaeedb6e541a36560b8a21567158e25
tree04f490bbae59932c019064d5b45890a4f24829d3
parentab45919812340c32ed4fb9ba9ca9962f4c5514b0
gh-143886: Ensure function annotations are returned in order of definition (#143888)

Ensure function annotations are returned in order of definition

Previously, when getting type annotations of a function, normal
arguments were returned before positional-only ones in the dictionary.
Since `functools.singledispatch` relies on this ordering being correct
to dispatch based on the type of the first argument, this issue was
causing incorrect registrations for functions with positional-only
arguments.

This commit updates how annotations are generated so that
positional-only arguments are generated and added to the dictionary
before normal arguments.
Lib/test/test_functools.py
Lib/test/test_typing.py
Misc/NEWS.d/next/Core_and_Builtins/2026-01-15-13-37-21.gh-issue-143886.2gk5QC.rst [new file with mode: 0644]
Python/codegen.c