-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
Conversation
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 |
Doc/library/dataclasses.rst
Outdated
- *unsafe_hash*: If false (the default), a :meth:`~object.__hash__` method | ||
is generated according to how *eq* and *frozen* are set. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Thanks @Viicos for the PR, and @ericvsmith for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14. |
…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>
GH-135416 is a backport of this pull request to the 3.14 branch. |
…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>
GH-135417 is a backport of this pull request to the 3.13 branch. |
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:
📚 Documentation preview 📚: https://cpython-previews--116532.org.readthedocs.build/