Skip to content

Commit

Permalink
Remove __ne__ where it's a simple wrapper of __eq__
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Dec 12, 2023
1 parent a798713 commit d83b409
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 24 deletions.
4 changes: 0 additions & 4 deletions src/coaster/sqlalchemy/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ def __eq__(self, other: t.Any) -> bool:
self.__composite_values__() == other.__composite_values__()
)

def __ne__(self, other: t.Any) -> bool:
"""Compare for inequality."""
return not self.__eq__(other)

# Pickle support methods implemented as per SQLAlchemy documentation, but not
# tested here as we don't use them.
# https://docs.sqlalchemy.org/en/13/orm/extensions/mutable.html#id1
Expand Down
11 changes: 0 additions & 11 deletions src/coaster/sqlalchemy/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,6 @@ def __eq__(self, other: t.Any) -> bool:
return self.obj == other.obj and self.actor == other.actor
return self._contents() == other

def __ne__(self, other: t.Any) -> bool:
return not self.__eq__(other)

def __and__(self, other: t.Iterable[str]) -> t.Set[str]:
"""Faster implementation that avoids lazy lookups where not needed."""
return {role for role in other if self._role_is_present(role)}
Expand Down Expand Up @@ -714,10 +711,6 @@ def __eq__(self, other: t.Any) -> bool:
and self.attr == other.attr
)

def __ne__(self, other: t.Any) -> bool:
# This method is required as abc.Set provides a less efficient version
return not self.__eq__(other)


class RoleAccessProxy(abc.Mapping, t.Generic[RoleMixinType]):
"""
Expand Down Expand Up @@ -986,10 +979,6 @@ def __eq__(self, other: t.Any) -> bool:
return True
return super().__eq__(other)

def __ne__(self, other: t.Any) -> bool:
# Don't call __eq__ directly, it may return NotImplemented
return not self == other

def __bool__(self) -> bool:
return bool(self._obj)

Expand Down
3 changes: 0 additions & 3 deletions src/coaster/sqlalchemy/statemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,6 @@ def __eq__(self, other: t.Any) -> bool:
and self._obj == other._obj
)

def __ne__(self, other: t.Any) -> bool:
return not self.__eq__(other)

def __bool__(self) -> bool:
return self._mstate.is_current_in(self._obj)

Expand Down
6 changes: 0 additions & 6 deletions src/coaster/views/classview.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,9 +663,6 @@ def current_handler(self) -> ViewMethodBind:
def __eq__(self, other: t.Any) -> bool:
return type(other) is type(self)

def __ne__(self, other: t.Any) -> bool:
return type(other) is not type(self)

def dispatch_request(
self, view: t.Callable[..., ResponseReturnValue], view_args: t.Dict[str, t.Any]
) -> BaseResponse:
Expand Down Expand Up @@ -954,9 +951,6 @@ def __init_subclass__(cls) -> None:
def __eq__(self, other: t.Any) -> bool:
return type(other) is type(self) and other.obj == self.obj

def __ne__(self, other: t.Any) -> bool:
return not self.__eq__(other)

def dispatch_request(
self, view: t.Callable[..., ResponseReturnValue], view_args: t.Dict[str, t.Any]
) -> BaseResponse:
Expand Down

0 comments on commit d83b409

Please sign in to comment.