Skip to content

Commit c7600b4

Browse files
authored
add type checking for graph __eq__ (#2531)
1 parent decd1f6 commit c7600b4

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

redis/commands/graph/edge.py

+4
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def __str__(self):
6161
return res
6262

6363
def __eq__(self, rhs):
64+
# Type checking
65+
if not isinstance(rhs, Edge):
66+
return False
67+
6468
# Quick positive check, if both IDs are set.
6569
if self.id is not None and rhs.id is not None and self.id == rhs.id:
6670
return True

redis/commands/graph/node.py

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ def __str__(self):
6565
return res
6666

6767
def __eq__(self, rhs):
68+
# Type checking
69+
if not isinstance(rhs, Node):
70+
return False
71+
6872
# Quick positive check, if both IDs are set.
6973
if self.id is not None and rhs.id is not None and self.id != rhs.id:
7074
return False

redis/commands/graph/path.py

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def add_edge(self, edge):
5454
return self
5555

5656
def __eq__(self, other):
57+
# Type checking
58+
if not isinstance(other, Path):
59+
return False
60+
5761
return self.nodes() == other.nodes() and self.edges() == other.edges()
5862

5963
def __str__(self):

0 commit comments

Comments
 (0)