Coverage for src/extratools_core/typing.py: 69%
16 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-06 23:52 -0700
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-06 23:52 -0700
1from abc import abstractmethod
2from typing import Protocol, Self, runtime_checkable
5@runtime_checkable
6class Comparable(Protocol): # noqa: PLW1641
7 """
8 Based on https://github.com/python/typing/issues/59
9 """
11 @abstractmethod
12 def __eq__(self, other: object) -> bool:
13 ...
15 @abstractmethod
16 def __lt__(self, other: Self) -> bool:
17 ...
19 def __gt__(self, other: Self) -> bool:
20 return (not self < other) and self != other
22 def __le__(self, other: Self) -> bool:
23 return self < other or self == other
25 def __ge__(self, other: Self) -> bool:
26 return (not self < other)