Bug 1681096 - python3 - pylint --py3k - W1641: Implementing __eq__ without also implementing __hash__ (eq-without-hash) r=marionette-reviewers,aki,gbrown,jgraham

Differential Revision: https://phabricator.services.mozilla.com/D99092
This commit is contained in:
Bob Clary 2020-12-11 12:21:32 +00:00
parent 286a2dd0d3
commit fbefc79bcb
5 changed files with 33 additions and 0 deletions

View File

@ -207,6 +207,10 @@ class HTMLElement(object):
def __eq__(self, other_element):
return self.id == other_element.id
def __hash__(self):
# pylint --py3k: W1641
return hash(self.id)
def find_element(self, method, target):
"""Returns an ``HTMLElement`` instance that matches the specified
method and target, relative to the current element.

View File

@ -36,6 +36,10 @@ class Message(object):
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
# pylint --py3k: W1641
return hash(self.id)
class Command(Message):
TYPE = 0

View File

@ -53,6 +53,10 @@ class StringVersion(six.text_type):
if self.version > other.version:
return 1
def __hash__(self):
# pylint --py3k: W1641
return hash(self.version)
# operator overloads
def __eq__(self, other):
return self._cmp(other) == 0

View File

@ -110,6 +110,10 @@ class Location(object):
__eq__ = isEqual
def __hash__(self):
# pylint --py3k: W1641
return hash(tuple(getattr(attr) for attr in self.attrs))
def url(self):
return "%s://%s:%s" % (self.scheme, self.host, self.port)

View File

@ -497,6 +497,19 @@ class FileRecord(object):
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
# pylint --py3k: W1641
return hash(
(
self.filename,
self.size,
self.digest,
self.algorithm,
self.version,
self.visibility,
)
)
def __str__(self):
return repr(self)
@ -669,6 +682,10 @@ class Manifest(object):
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
# pylint --py3k: W1641
return hash(tuple(sorted((fr.filename, fr) for fr in self.file_records)))
def __deepcopy__(self, memo):
# This is required for a deep copy
return Manifest(self.file_records[:])