Skip to content

PLW1641/eq-without-hash should not trigger when explicitly setting __hash__ = None #6701

@bluetech

Description

@bluetech

Given

class MyClass:
    def __eq__(self, other):
        return True

    __hash__ = None

Running ruff --isolated --select PLW1641 with Ruff 0.0.285:

x.py:1:7: PLW1641 Object does not implement `__hash__` method

While the purpose of PLW1641 is exactly to check for when __eq__ is defined and __hash__ is None (the default when __eq__ is defined but __hash__ is not), I think that if the code explicitly sets __hash__ = None then the lint should not trigger since the programmer explicitly asks for it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedReady for implementationbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions