Improve documentation for ShaFile.__lt__, __le__, __cmp__.
authorJelmer Vernooij <jelmer@jelmer.uk>
Thu, 27 Dec 2018 21:50:21 +0000 (21:50 +0000)
committerJelmer Vernooij <jelmer@jelmer.uk>
Thu, 27 Dec 2018 21:50:21 +0000 (21:50 +0000)
dulwich/objects.py

index ced6be9115959041e03bf22c0b78fec8a8ea29e4..8e224162104b101b21c4ae697a2444849ed68268 100644 (file)
@@ -520,27 +520,31 @@ class ShaFile(object):
         return "<%s %s>" % (self.__class__.__name__, self.id)
 
     def __ne__(self, other):
+        """Check whether this object does not match the other."""
         return not isinstance(other, ShaFile) or self.id != other.id
 
     def __eq__(self, other):
         """Return True if the SHAs of the two objects match.
-
-        It doesn't make sense to talk about an order on ShaFiles, so we don't
-        override the rich comparison methods (__le__, etc.).
         """
         return isinstance(other, ShaFile) and self.id == other.id
 
     def __lt__(self, other):
+        """Return whether SHA of this object is less than the other.
+        """
         if not isinstance(other, ShaFile):
             raise TypeError
         return self.id < other.id
 
     def __le__(self, other):
+        """Check whether SHA of this object is less than or equal to the other.
+        """
         if not isinstance(other, ShaFile):
             raise TypeError
         return self.id <= other.id
 
     def __cmp__(self, other):
+        """Compare the SHA of this object with that of the other object.
+        """
         if not isinstance(other, ShaFile):
             raise TypeError
         return cmp(self.id, other.id)  # noqa: F821