Skip to content

Commit

Permalink
Remove the Comparable protocol. (#129)
Browse files Browse the repository at this point in the history
We don't use it anymore, and it is not useful for static analysis
(you only need to implement a subset of the methods to support all
comparisons) nor at runtime (every object implements all of the `__xx__`
methods, but most return `NotImplemented`, meaning that
`isinstance(anything, Comparable)` was always true even for things that
were not comparable, like regular old `object()`.
  • Loading branch information
thetorpedodog authored Feb 15, 2023
1 parent 1482d48 commit 26bf177
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions python-spec/src/somacore/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import sys
from typing import Any, NoReturn, Optional, Type, TypeVar, Sequence, TYPE_CHECKING
from typing_extensions import Protocol, Self, TypeGuard
from typing_extensions import Protocol, TypeGuard


def is_nonstringy_sequence(it: Any) -> TypeGuard[Sequence]:
Expand All @@ -15,28 +15,6 @@ def is_nonstringy_sequence(it: Any) -> TypeGuard[Sequence]:
return not isinstance(it, (str, bytes)) and isinstance(it, Sequence)


class Comparable(Protocol):
"""Objects that can be ``<``/``==``/``>``'d."""

def __lt__(self, __other: Self) -> bool:
...

def __le__(self, __other: Self) -> bool:
...

def __eq__(self, __other: object) -> bool:
...

def __ne__(self, __other: object) -> bool:
...

def __ge__(self, __other: Self) -> bool:
...

def __gt__(self, __other: Self) -> bool:
...


_T = TypeVar("_T")
_T_co = TypeVar("_T_co", covariant=True)

Expand Down

0 comments on commit 26bf177

Please sign in to comment.