Skip to content

Fix format of dataclasses' unsafe_hash default value #116532

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

Merged
merged 4 commits into from
Jun 12, 2025

Conversation

Viicos
Copy link
Contributor

@Viicos Viicos commented Mar 9, 2024

To be in line with the other parameters. I wonder what is the precedent here: should every default value be wrapped in preformatted text? For the other dataclass parameters, only the default value is, but not the actual if true/false:

``order``: If true (the default is ``False``)

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

@Viicos Viicos requested a review from ericvsmith as a code owner March 9, 2024 08:14
@bedevere-app bedevere-app bot added awaiting review docs Documentation in the Doc dir skip news labels Mar 9, 2024
@ericvsmith
Copy link
Member

The intent is that it's saying any value that evaluates as false in a boolean context. It's a little confusing to say "If false (the default is False)", but that's the more technically correct version.

@Viicos
Copy link
Contributor Author

Viicos commented Jun 30, 2024

The goal here was just to make the formatting consistent with other parameters. For instance for eq:

image

So this switches from:

``False``

to false

Comment on lines 124 to 125
- *unsafe_hash*: If false (the default), a :meth:`~object.__hash__` method
is generated according to how *eq* and *frozen* are set.
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps "If true, force dataclasses to create a __hash__ method, even when it may not be safe to do so. Otherwise, generate a __hash__ method according to how eq and frozen are set. The default value is False."

or words to that effect?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think this is the best approach. It could be extended to the default=True values as well: put the default at the end.

@AA-Turner AA-Turner added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Jun 11, 2025
@ericvsmith ericvsmith merged commit 71f5faf into python:main Jun 12, 2025
34 checks passed
@miss-islington-app
Copy link

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

@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs Jun 12, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 12, 2025
…H-116532)

(cherry picked from commit 71f5fafdfb2e509f59cd584d45949c6496f88d41)

Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Jun 12, 2025

GH-135416 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 12, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 12, 2025
…H-116532)

(cherry picked from commit 71f5fafdfb2e509f59cd584d45949c6496f88d41)

Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
@bedevere-app
Copy link

bedevere-app bot commented Jun 12, 2025

GH-135417 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 12, 2025
ericvsmith pushed a commit that referenced this pull request Jun 12, 2025
…H-116532) (#135416)

Fix presentation of dataclasses' `unsafe_hash` default value (GH-116532)

(cherry picked from commit 71f5faf)

Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
ericvsmith pushed a commit that referenced this pull request Jun 12, 2025
…H-116532) (#135417)

Fix presentation of dataclasses' `unsafe_hash` default value (GH-116532)

(cherry picked from commit 71f5faf)

Co-authored-by: Victorien <65306057+Viicos@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy