3 # © Copyright 2021-2023, Scott Gasch
7 from abc import abstractmethod
8 from typing import Any, Protocol, Union
10 Numeric = Union[int, float]
13 class Comparable(Protocol):
14 """Anything that implements basic comparison methods such that it
15 can be compared to other instances of the same type.
17 Check out :meth:`functools.total_ordering`
18 (https://docs.python.org/3/library/functools.html#functools.total_ordering)
19 for an easy way to make your type comparable.
23 def __lt__(self, other: Any) -> bool:
27 def __le__(self, other: Any) -> bool:
31 def __eq__(self, other: Any) -> bool:
35 class Closable(Protocol):
36 """Something that can be closed."""
38 def close(self) -> None:
42 class Cloneable(Protocol):
43 """Something that can be cloned."""
45 def clone(self) -> None:
49 class Runnable(Protocol):
50 """Something that can be run."""
52 def run(self) -> None: