Update src/pip/_internal/models/format_control.py

Co-authored-by: Pradyun Gedam <pradyunsg@gmail.com>
This commit is contained in:
Cristina 2020-06-02 09:50:16 -07:00 committed by GitHub
parent 330323bf8b
commit 5f0f2f0218
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 7 deletions

View File

@ -27,14 +27,16 @@ class FormatControl(object):
def __eq__(self, other):
# type: (object) -> bool
if isinstance(other, self.__class__):
if self.__slots__ == other.__slots__:
attr_getters = [operator.attrgetter(attr)
for attr in self.__slots__]
return all(getter(self) == getter(other)
for getter in attr_getters)
if not isinstance(other, self.__class__):
return NotImplemented
if self.__slots__ != other.__slots__:
return NotImplemented
return False
return all(
getattr(self, k) == getattr(other, k)
for k in self.__slots__
)
def __ne__(self, other):
# type: (object) -> bool