Skip to content

Clarify the meaning dataclasses.field(..., hash=False) #130130

@picnixz

Description

@picnixz

See https://discuss.python.org/t/unclear-docs-for-dataclasses-field/80716. Currently the docs are:

hash: This can be a bool or None. If true, this field is included in the generated __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 other than None is discouraged.

We can change it to

 hash: This can be a bool or None. If true, this field is included in the generated :meth:`~object.__hash__` method.
+If false, this field is excluded from the generated :meth:`~object.__hash__` method.
 If :const:`None` (the default), use the value of compare: this would normally be the expected behavior.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions