Skip to content

Move dataclass kw_only fields to the end of the signature #19018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sterliakov
Copy link
Collaborator

@sterliakov sterliakov commented May 3, 2025

Fixes #19017. Fixes #17731.

This is a rather naive change: python does that at runtime. kw_only args can be in any order, and non-kwonly args should remain sorted as-is (stable sort). I don't understand why this was only done in presence of a parent dataclass - AFAIC kwonly fields work that way since kw_only was introduced in py3.10.

The test I changed was invalid and asserted a false positive to the best of my knowledge.

Copy link
Contributor

github-actions bot commented May 3, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@sterliakov sterliakov marked this pull request as ready for review May 3, 2025 16:33
@sterliakov sterliakov requested a review from A5rocks May 3, 2025 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant