Skip to content

gh-138991: Update dataclass documentation for new eq behavior in Python 3.13 and add tests#139007

Merged
vstinner merged 11 commits into
python:mainfrom
Aniketsy:dataclass-eq-doc-update-3-13
Jun 11, 2026
Merged

gh-138991: Update dataclass documentation for new eq behavior in Python 3.13 and add tests#139007
vstinner merged 11 commits into
python:mainfrom
Aniketsy:dataclass-eq-doc-update-3-13

Conversation

@Aniketsy

@Aniketsy Aniketsy commented Sep 16, 2025

Copy link
Copy Markdown
Contributor

#138991
This PR updates the documentation for the eq parameter in the dataclasses module to reflect the new field-by-field comparison behavior introduced in Python 3.13.
A .. versionchanged:: 3.13 notice has been added, and the previous tuple-based comparison for Python 3.12 and earlier is described for clarity.

Additionally, new tests have been added to verify the updated __eq__ implementation, including field-by-field comparison, type checking, and custom field equality logic.

Please let me know if my approach or fix needs any improvements . I’m open to feedback and happy to make changes based on suggestions.
Thankyou !


📚 Documentation preview 📚: https://cpython-previews--139007.org.readthedocs.build/

@bedevere-app

This comment was marked as resolved.

Comment thread Doc/library/dataclasses.rst Outdated
Comment thread Lib/test/test_dataclasses/__init__.py
Comment thread Doc/library/dataclasses.rst Outdated
Comment thread Doc/library/dataclasses.rst Outdated
@bedevere-app

bedevere-app Bot commented Sep 17, 2025

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ericvsmith ericvsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use more specific unittest methods.

Comment thread Lib/test/test_dataclasses/__init__.py Outdated
Comment thread Lib/test/test_dataclasses/__init__.py Outdated
Comment thread Lib/test/test_dataclasses/__init__.py Outdated
@Aniketsy

Copy link
Copy Markdown
Contributor Author

@ericvsmith please review these changes when you get a chance.

@Aniketsy Aniketsy force-pushed the dataclass-eq-doc-update-3-13 branch from 03445c6 to 61af25c Compare November 8, 2025 13:32
@Aniketsy

Aniketsy commented Nov 8, 2025

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again .

@bedevere-app

bedevere-app Bot commented Nov 8, 2025

Copy link
Copy Markdown

Thanks for making the requested changes!

@ericvsmith: please review the changes made to this pull request.

@bedevere-app bedevere-app Bot requested a review from ericvsmith November 8, 2025 13:33
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 29, 2026
Comment thread Doc/library/dataclasses.rst Outdated
Comment thread Doc/library/dataclasses.rst Outdated
@Aniketsy

Copy link
Copy Markdown
Contributor Author

@vstinner thanks for the review, i've updated please let me know if we need further improvements in this.

@read-the-docs-community

read-the-docs-community Bot commented Jun 11, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33097812 | 📁 Comparing 4991c6a against main (10595b1)

  🔍 Preview build  

1 file changed
± library/dataclasses.html

@vstinner vstinner dismissed ericvsmith’s stale review June 11, 2026 16:23

Use more specific unittest methods.

This reviews has been addressed. The tests now use assertEqual() and assertNotEqual() properly.

@vstinner

Copy link
Copy Markdown
Member

Tests / Docs / Docs (pull_request): Failing after 15s

It failed on git fetch with fatal: shallow file has changed since we read it. Aha, that's just a random error.

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. The doc is rendered correctly, I checked.

@vstinner

Copy link
Copy Markdown
Member

Oh, the "Docs / Docs" CI now fails with:

Run python Doc/tools/check-html-ids.py collect Doc/build/html -o Doc/build/html-ids-head.json.gz
python: can't open file '/home/runner/work/cpython/cpython/Doc/tools/check-html-ids.py': [Errno 2] No such file or directory

Let me click on [Update branch] to solve the issue.

@vstinner vstinner enabled auto-merge (squash) June 11, 2026 16:29
@vstinner vstinner added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Jun 11, 2026
@Aniketsy

Copy link
Copy Markdown
Contributor Author

thanks for merging, and moving this forward.

@vstinner vstinner merged commit 402668b into python:main Jun 11, 2026
141 of 145 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @Aniketsy for the PR, and @vstinner for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@bedevere-app

bedevere-app Bot commented Jun 11, 2026

Copy link
Copy Markdown

GH-151372 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Jun 11, 2026
@bedevere-app

bedevere-app Bot commented Jun 11, 2026

Copy link
Copy Markdown

GH-151373 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Jun 11, 2026
@bedevere-app

bedevere-app Bot commented Jun 11, 2026

Copy link
Copy Markdown

GH-151374 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Jun 11, 2026
@vstinner

Copy link
Copy Markdown
Member

fatal: shallow file has changed since we read it

I created #151365 to track this issue.

@vstinner

Copy link
Copy Markdown
Member

PR merged. Thanks @Aniketsy for updating the doc and writing some tests!

vstinner added a commit that referenced this pull request Jun 11, 2026
…in Python 3.13 (GH-139007) (#151374)

gh-138991: Update dataclass documentation for new eq behavior in Python 3.13 (GH-139007)

And add tests.
(cherry picked from commit 402668b)

Co-authored-by: Aniket <148300120+Aniketsy@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this pull request Jun 11, 2026
…in Python 3.13 (GH-139007) (#151373)

gh-138991: Update dataclass documentation for new eq behavior in Python 3.13 (GH-139007)

And add tests.
(cherry picked from commit 402668b)

Co-authored-by: Aniket <148300120+Aniketsy@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner added a commit that referenced this pull request Jun 11, 2026
…in Python 3.13 (GH-139007) (#151372)

gh-138991: Update dataclass documentation for new eq behavior in Python 3.13 (GH-139007)

And add tests.
(cherry picked from commit 402668b)

Co-authored-by: Aniket <148300120+Aniketsy@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants