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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
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