Demonstration of the issue:
import once
class Foo:
def __init__(self, a: int):
self.a = a
# defining this without __hash__ make unhashable
def __eq__(self, other) -> bool:
if isinstance(other, Foo):
return self.value == other.value
return NotImplemented
@once.once_per_instance
def b(self) -> int:
return self.a
a = Foo(a=1)
a.b()
This gives TypeError: unhashable type: 'Foo'
Demonstration of the issue:
This gives
TypeError: unhashable type: 'Foo'