from abc import ABC class MyHashable(ABC): @classmethod def __subclasshook__(cls, sbcls): hash_func = getattr(sbcls, "__hash__", None) return hash_func is not None