Dulwich.io dulwich / 8b58822
Improve documentation for ShaFile.__lt__, __le__, __cmp__. Jelmer Vernooń≥ 19 days ago
1 changed file(s) with 7 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
519519 return "<%s %s>" % (self.__class__.__name__, self.id)
520520
521521 def __ne__(self, other):
522 """Check whether this object does not match the other."""
522523 return not isinstance(other, ShaFile) or self.id != other.id
523524
524525 def __eq__(self, other):
525526 """Return True if the SHAs of the two objects match.
526
527 It doesn't make sense to talk about an order on ShaFiles, so we don't
528 override the rich comparison methods (__le__, etc.).
529527 """
530528 return isinstance(other, ShaFile) and self.id == other.id
531529
532530 def __lt__(self, other):
531 """Return whether SHA of this object is less than the other.
532 """
533533 if not isinstance(other, ShaFile):
534534 raise TypeError
535535 return self.id < other.id
536536
537537 def __le__(self, other):
538 """Check whether SHA of this object is less than or equal to the other.
539 """
538540 if not isinstance(other, ShaFile):
539541 raise TypeError
540542 return self.id <= other.id
541543
542544 def __cmp__(self, other):
545 """Compare the SHA of this object with that of the other object.
546 """
543547 if not isinstance(other, ShaFile):
544548 raise TypeError
545549 return cmp(self.id, other.id) # noqa: F821