Skip to content

Commit 16a06be

Browse files
[3.12] gh-130130: Clarify hash=False docs in dataclasses.field (GH-130324) (#130336)
gh-130130: Clarify `hash=False` docs in `dataclasses.field` (GH-130324) (cherry picked from commit 47ace53) Co-authored-by: Sabfo <[email protected]>
1 parent 4fb2bb6 commit 16a06be

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Doc/library/dataclasses.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,11 @@ Module contents
277277
string returned by the generated :meth:`~object.__repr__` method.
278278

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

286287
One possible reason to set ``hash=False`` but ``compare=True``

0 commit comments

Comments
 (0)