Skip to content

Do not sort OrderedDict keyword arguments#51

Merged
bboe merged 1 commit into
mainfrom
fix-ordereddict-kwargs
Jun 15, 2026
Merged

Do not sort OrderedDict keyword arguments#51
bboe merged 1 commit into
mainfrom
fix-ordereddict-kwargs

Conversation

@bboe

@bboe bboe commented Jun 15, 2026

Copy link
Copy Markdown
Member

OrderedDict(b=2, a=1) iterates in argument order and is a distinct, unequal value from OrderedDict(a=1, b=2), so alphabetizing its keyword arguments changed the resulting object.

This exempts calls to OrderedDict (bare or dotted, e.g. collections.OrderedDict) from keyword-argument sorting via a new ORDER_SENSITIVE_CALLS set. A test_order_sensitive_calls fixture covers both forms alongside the regular-call and dict-literal cases that must still sort.

OrderedDict(b=2, a=1) iterates in argument order and is a distinct,
unequal value from OrderedDict(a=1, b=2), so alphabetizing its keyword
arguments changed the resulting object. Exempt calls to OrderedDict
(bare or dotted, such as collections.OrderedDict) from keyword-argument
sorting via a new ORDER_SENSITIVE_CALLS set.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bboe bboe merged commit 5f0e226 into main Jun 15, 2026
9 checks passed
@bboe bboe deleted the fix-ordereddict-kwargs branch June 15, 2026 21:29
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.

1 participant