-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
questionAsking for support or clarificationAsking for support or clarification
Description
The current eq-without-hash
(PLW1641) rule warns whenever a class defines __eq__
without defining __hash__
. However, this creates false positives for legitimate use cases.
Not all classes with __eq__
are intended to be used as dictionary keys or set members. For mutable objects, having __hash__ = None
is actually the correct behavior according to Python's data model:
Consider the inverse check instead: warn when a class defines __hash__
(and it's not None) but doesn't define __eq__
. This would catch cases where the hash/equality contract is violated: objects that are equal must have the same hash value.

Metadata
Metadata
Assignees
Labels
questionAsking for support or clarificationAsking for support or clarification