Skip to content

gh-130130: Clarify hash=False docs in dataclasses.field #130324

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 2 commits into from
Feb 20, 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
9 changes: 5 additions & 4 deletions Doc/library/dataclasses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,11 @@ Module contents
string returned by the generated :meth:`~object.__repr__` method.

- *hash*: This can be a bool or ``None``. If true, this field is
included in the generated :meth:`~object.__hash__` method. If ``None`` (the
default), use the value of *compare*: this would normally be
the expected behavior. A field should be considered in the hash
if it's used for comparisons. Setting this value to anything
included in the generated :meth:`~object.__hash__` method. If false,
this field is excluded from the generated :meth:`~object.__hash__`.
If ``None`` (the default), use the value of *compare*: this would
normally be the expected behavior, since a field should be included
in the hash if it's used for comparisons. Setting this value to anything
other than ``None`` is discouraged.

One possible reason to set ``hash=False`` but ``compare=True``
Expand Down
Loading