Skip to content

Commit

Permalink
Remove __ne__ methods (#7257)
Browse files Browse the repository at this point in the history
* Remove __ne__ methods

These are already defined as the opposite of __eq__ in Python 3, and when __eq__
returns NotImplemented, Python by default will return True.

* Remove with_unique_field.__ne__
  • Loading branch information
atombrella committed Mar 6, 2022
1 parent 4de59d8 commit 4a6bdb2
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 44 deletions.
8 changes: 0 additions & 8 deletions celery/beat.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,6 @@ def __eq__(self, other):
"""
return self.editable_fields_equal(other)

def __ne__(self, other):
"""Test schedule entries inequality.
Will only compare "editable" fields:
``task``, ``schedule``, ``args``, ``kwargs``, ``options``.
"""
return not self == other


def _evaluate_entry_args(entry_args):
if not entry_args:
Expand Down
5 changes: 0 additions & 5 deletions celery/events/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ def __eq__(this, other):
return NotImplemented
cls.__eq__ = __eq__

def __ne__(this, other):
res = this.__eq__(other)
return True if res is NotImplemented else not res
cls.__ne__ = __ne__

def __hash__(this):
return hash(getattr(this, attr))
cls.__hash__ = __hash__
Expand Down
12 changes: 0 additions & 12 deletions celery/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,6 @@ def __eq__(self, other):
return other == self.id
return NotImplemented

def __ne__(self, other):
res = self.__eq__(other)
return True if res is NotImplemented else not res

def __copy__(self):
return self.__class__(
self.id, self.backend, None, self.app, self.parent,
Expand Down Expand Up @@ -830,10 +826,6 @@ def __eq__(self, other):
return other.results == self.results
return NotImplemented

def __ne__(self, other):
res = self.__eq__(other)
return True if res is NotImplemented else not res

def __repr__(self):
return f'<{type(self).__name__}: [{", ".join(r.id for r in self.results)}]>'

Expand Down Expand Up @@ -925,10 +917,6 @@ def __eq__(self, other):
return other == self.id
return NotImplemented

def __ne__(self, other):
res = self.__eq__(other)
return True if res is NotImplemented else not res

def __repr__(self):
return f'<{type(self).__name__}: {self.id} [{", ".join(r.id for r in self.results)}]>'

Expand Down
15 changes: 0 additions & 15 deletions celery/schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ def __eq__(self, other):
return self.run_every == other.run_every
return self.run_every == other

def __ne__(self, other):
return not self.__eq__(other)

def __reduce__(self):
return self.__class__, (self.run_every, self.relative, self.nowfun)

Expand Down Expand Up @@ -638,12 +635,6 @@ def __eq__(self, other):
)
return NotImplemented

def __ne__(self, other):
res = self.__eq__(other)
if res is NotImplemented:
return True
return not res


def maybe_schedule(s, relative=False, app=None):
"""Return schedule from number, timedelta, or actual schedule."""
Expand Down Expand Up @@ -827,9 +818,3 @@ def __eq__(self, other):
other.lon == self.lon
)
return NotImplemented

def __ne__(self, other):
res = self.__eq__(other)
if res is NotImplemented:
return True
return not res
4 changes: 0 additions & 4 deletions celery/utils/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,10 +628,6 @@ def __eq__(self, other):
# type: (Any) -> bool
return self._data == other._data

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

def __repr__(self):
# type: () -> str
return REPR_LIMITED_SET.format(
Expand Down

0 comments on commit 4a6bdb2

Please sign in to comment.