Skip to content

gh-143886: Ensure function annotations are returned in order of definition#143888

Merged
JelleZijlstra merged 1 commit intopython:mainfrom
pR0Ps:bugfix/annotations-order
Apr 15, 2026
Merged

gh-143886: Ensure function annotations are returned in order of definition#143888
JelleZijlstra merged 1 commit intopython:mainfrom
pR0Ps:bugfix/annotations-order

Conversation

@pR0Ps
Copy link
Copy Markdown
Contributor

@pR0Ps pR0Ps commented Jan 15, 2026

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 PR updates how annotations are generated so that positional-only arguments are generated and added to the dictionary before normal arguments.

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.
@pR0Ps pR0Ps force-pushed the bugfix/annotations-order branch from 31d6239 to f709913 Compare April 15, 2026 12:55
@JelleZijlstra JelleZijlstra merged commit cb339d3 into python:main Apr 15, 2026
54 checks passed
@pR0Ps pR0Ps deleted the bugfix/annotations-order branch April 15, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants