Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-144191: Dataclasses single field ordering#144222

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
whyvineet wants to merge6 commits intopython:main
base:main
Choose a base branch
Loading
fromwhyvineet:dataclasses-single-field-ordering

Conversation

@whyvineet
Copy link

@whyvineetwhyvineet commentedJan 25, 2026
edited by bedevere-appbot
Loading

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

Copy link
Member

@johnslavikjohnslavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks! You can wait for the green light from Eric before going forward or add tests for this even now. I'd probably changetest_1_field_compare. And of course a news entry, too.

Comment on lines 1183 to 1188
iflen(flds)==1:
self_expr=f"self.{flds[0].name}"
other_expr=f"other.{flds[0].name}"
else:
self_expr=_tuple_str('self',flds)
other_expr=_tuple_str('other',flds)
Copy link
Member

@johnslavikjohnslavikJan 26, 2026
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is how I'd approach it:

Suggested change
iflen(flds)==1:
self_expr=f"self.{flds[0].name}"
other_expr=f"other.{flds[0].name}"
else:
self_expr=_tuple_str('self',flds)
other_expr=_tuple_str('other',flds)
matchflds:
# Special-case single field comparisons. See GH-144191.
case [single_fld]:
self_expr=f'self.{single_fld.name}'
other_expr=f'other.{single_fld.name}'
case_:
self_expr=_tuple_str('self',flds)
other_expr=_tuple_str('other',flds)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks! I’ve updated the logic using match/case. It’s more readable and makes the intent clearer.

@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@johnslavikjohnslavikjohnslavik left review comments

@ericvsmithericvsmithAwaiting requested review from ericvsmithericvsmith is a code owner

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@whyvineet@johnslavik

[8]ページ先頭

©2009-2026 Movatter.jp