Merge pull request #9401 from jdufresne/ne

Remove unnecessary __ne__ definitions
This commit is contained in:
Stéphane Bidoul 2021-01-01 19:38:09 +01:00 committed by GitHub
commit 062f0e54d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1 additions and 24 deletions

View File

@ -36,10 +36,6 @@ class FormatControl:
for k in self.__slots__
)
def __ne__(self, other):
# type: (object) -> bool
return not self.__eq__(other)
def __repr__(self):
# type: () -> str
return "{}({}, {})".format(

View File

@ -164,11 +164,6 @@ class _InstallRequirementBackedCandidate(Candidate):
return self._link == other._link
return False
# Needed for Python 2, which does not implement this by default
def __ne__(self, other):
# type: (Any) -> bool
return not self.__eq__(other)
@property
def source_link(self):
# type: () -> Optional[Link]
@ -378,11 +373,6 @@ class AlreadyInstalledCandidate(Candidate):
return self.name == other.name and self.version == other.version
return False
# Needed for Python 2, which does not implement this by default
def __ne__(self, other):
# type: (Any) -> bool
return not self.__eq__(other)
@property
def project_name(self):
# type: () -> str
@ -475,11 +465,6 @@ class ExtrasCandidate(Candidate):
return self.base == other.base and self.extras == other.extras
return False
# Needed for Python 2, which does not implement this by default
def __ne__(self, other):
# type: (Any) -> bool
return not self.__eq__(other)
@property
def project_name(self):
# type: () -> str

View File

@ -34,9 +34,6 @@ class KeyBasedCompareMixin:
def __eq__(self, other):
return self._compare(other, operator.__eq__)
def __ne__(self, other):
return self._compare(other, operator.__ne__)
def _compare(self, other, method):
if not isinstance(other, self._defining_class):
return NotImplemented

View File

@ -847,8 +847,7 @@ class TestHiddenText:
hidden2 = HiddenText('secret', redacted='####')
assert hidden1 == hidden2
# Also test __ne__. This assertion fails in Python 2 without
# defining HiddenText.__ne__.
# Also test __ne__.
assert not hidden1 != hidden2
def test_equality_different_secret(self):