Skip to content

Commit 47ace53

Browse files
authored
gh-130130: Clarify hash=False docs in dataclasses.field (#130324)
1 parent 1b07006 commit 47ace53

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
@@ -270,10 +270,11 @@ Module contents
270270
string returned by the generated :meth:`~object.__repr__` method.
271271

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

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

0 commit comments

Comments
 (0)