Coverage for src/extratools_core/typing.py: 0%
17 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-05 23:54 -0700
« prev ^ index » next coverage.py v7.8.0, created at 2025-04-05 23:54 -0700
1from __future__ import annotations
3from abc import abstractmethod
4from typing import Protocol, runtime_checkable
7@runtime_checkable
8class Comparable(Protocol): # noqa: PLW1641
9 """
10 Based on https://github.com/python/typing/issues/59
11 """
13 @abstractmethod
14 def __eq__(self, other: object) -> bool:
15 ...
17 @abstractmethod
18 def __lt__(self, other: Comparable) -> bool:
19 ...
21 def __gt__(self, other: Comparable) -> bool:
22 return (not self < other) and self != other
24 def __le__(self, other: Comparable) -> bool:
25 return self < other or self == other
27 def __ge__(self, other: Comparable) -> bool:
28 return (not self < other)