Browse Source

Define __ne__ when __eq__

Ask Solem 11 years ago
parent
commit
cd27aef18a
4 changed files with 21 additions and 0 deletions
  1. 3 0
      celery/datastructures.py
  2. 9 0
      celery/result.py
  3. 6 0
      celery/schedules.py
  4. 3 0
      celery/utils/timer2.py

+ 3 - 0
celery/datastructures.py

@@ -629,6 +629,9 @@ class LimitedSet(object):
     def __eq__(self, other):
         return self._heap == other._heap
 
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
     def __repr__(self):
         return 'LimitedSet({0})'.format(len(self))
 

+ 9 - 0
celery/result.py

@@ -214,6 +214,9 @@ class AsyncResult(ResultBase):
             return other == self.id
         return NotImplemented
 
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
     def __copy__(self):
         r = self.__reduce__()
         return r[0](*r[1])
@@ -561,6 +564,9 @@ class ResultSet(ResultBase):
             return other.results == self.results
         return NotImplemented
 
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
     def __repr__(self):
         return '<{0}: [{1}]>'.format(type(self).__name__,
                                      ', '.join(r.id for r in self.results))
@@ -625,6 +631,9 @@ class GroupResult(ResultSet):
             return other.id == self.id and other.results == self.results
         return NotImplemented
 
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
     def __repr__(self):
         return '<{0}: {1} [{2}]>'.format(type(self).__name__, self.id,
                                          ', '.join(r.id for r in self.results))

+ 6 - 0
celery/schedules.py

@@ -111,6 +111,9 @@ class schedule(object):
             return self.run_every == other.run_every
         return self.run_every == other
 
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
     @property
     def seconds(self):
         return timedelta_seconds(self.run_every)
@@ -528,6 +531,9 @@ class crontab(schedule):
                     other.minute == self.minute)
         return other is self
 
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
 
 def maybe_schedule(s, relative=False):
     if isinstance(s, int):

+ 3 - 0
celery/utils/timer2.py

@@ -81,6 +81,9 @@ class Entry(object):
         def __eq__(self, other):
             return hash(self) == hash(other)
 
+        def __ne__(self, other):
+            return not self.__eq__(other)
+
 
 def to_timestamp(d, default_timezone=timezone.utc):
     if isinstance(d, datetime):