Skip to content

Commit 546d7ff

Browse files
Fix __eq__ and __ne__. (#3765)
1 parent a5c8d80 commit 546d7ff

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/google-cloud-datastore/google/cloud/datastore/entity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def __eq__(self, other):
146146
:returns: True if the entities compare equal, else False.
147147
"""
148148
if not isinstance(other, Entity):
149-
return False
149+
return NotImplemented
150150

151151
return (self.key == other.key and
152152
self.exclude_from_indexes == other.exclude_from_indexes and
@@ -162,7 +162,7 @@ def __ne__(self, other):
162162
:rtype: bool
163163
:returns: False if the entities compare equal, else True.
164164
"""
165-
return not self.__eq__(other)
165+
return not self == other
166166

167167
@property
168168
def kind(self):

packages/google-cloud-datastore/google/cloud/datastore/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ def __eq__(self, other):
454454
:returns: True if the points compare equal, else False.
455455
"""
456456
if not isinstance(other, GeoPoint):
457-
return False
457+
return NotImplemented
458458

459459
return (self.latitude == other.latitude and
460460
self.longitude == other.longitude)
@@ -465,4 +465,4 @@ def __ne__(self, other):
465465
:rtype: bool
466466
:returns: False if the points compare equal, else True.
467467
"""
468-
return not self.__eq__(other)
468+
return not self == other

packages/google-cloud-datastore/google/cloud/datastore/key.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def __eq__(self, other):
123123
:returns: True if the keys compare equal, else False.
124124
"""
125125
if not isinstance(other, Key):
126-
return False
126+
return NotImplemented
127127

128128
if self.is_partial or other.is_partial:
129129
return False
@@ -143,7 +143,7 @@ def __ne__(self, other):
143143
:rtype: bool
144144
:returns: False if the keys compare equal, else True.
145145
"""
146-
return not self.__eq__(other)
146+
return not self == other
147147

148148
def __hash__(self):
149149
"""Hash a keys for use in a dictionary lookp.

0 commit comments

Comments
 (0)