request.py 531 B

1234567891011121314151617181920212223
  1. from abc import abstractmethod
  2. class AdapterRequest:
  3. """
  4. Base class for adapter requests.
  5. """
  6. @property
  7. @abstractmethod
  8. def adapter_id(self):
  9. ...
  10. def __post_init__(self):
  11. if self.adapter_id < 1:
  12. raise ValueError(f"id must be > 0, got {self.adapter_id}")
  13. def __eq__(self, value: object) -> bool:
  14. return isinstance(
  15. value, self.__class__) and self.adapter_id == value.adapter_id
  16. def __hash__(self) -> int:
  17. return hash(self.adapter_id)