Skip to content

Redis model does not implement __hash__. #1275

@domol

Description

@domol

Version: 3.4.0

Platform: Python 3.7

Description:
in the new version Redis model has __eq__ implemented but not __hash__.
Python docs(https://docs.python.org/3/reference/datamodel.html#object.__hash):

if it defines eq() but not hash(), its instances will not be usable as items in hashable collections.

A class that overrides eq() and does not define hash() will have its hash() implicitly set to None. When the hash() method of a class is None, instances of the class will raise an appropriate TypeError when a program attempts to retrieve their hash value, and will also be correctly identified as unhashable when checking isinstance(obj, collections.abc.Hashable).

If a class that overrides eq() needs to retain the implementation of hash() from a parent class, the interpreter must be told this explicitly by setting hash = .hash.

Shouldn't Redis implement __hash__ then?

There is an issue with kombu related to it: celery/kombu#1152

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions