8000 [3.13] Fix presentation of dataclasses' `unsafe_hash` default value (GH-116532) by miss-islington · Pull Request #135417 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

[3.13] Fix presentation of dataclasses' unsafe_hash default value (GH-116532) #135417

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 1 commit into from
Jun 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
  • Loading branch information
2 people authored and miss-islington committed Jun 12, 2025
commit 92d8878cb6da3559debc6004e14a51a1f9f04ca4
7 changes: 5 additions & 2 deletions Doc/library/dataclasses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ Module contents
:meth:`!__le__`, :meth:`!__gt__`, or :meth:`!__ge__`, then
:exc:`TypeError` is raised.

- *unsafe_hash*: If ``False`` (the default), a :meth:`~object.__hash__` method
is generated according to how *eq* and *frozen* are set.
- *unsafe_hash*: If true, force ``dataclasses`` to create a
:meth:`~object.__hash__` method, even though it may not be safe to do so.
Otherwise, generate a :meth:`~object.__hash__` method according to how
*eq* and *frozen* are set.
The default value is ``False``.

:meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are
added to hashed collections such as dictionaries and sets. Having a
Expand Down
Loading
0