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
Родитель 286a2dd0d3
Коммит fbefc79bcb
5 изменённых файлов: 33 добавлений и 0 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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)

Просмотреть файл

@ -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[:])