diff --git a/redis/commands/graph/edge.py b/redis/commands/graph/edge.py index b0141d9452..6ee195f1f5 100644 --- a/redis/commands/graph/edge.py +++ b/redis/commands/graph/edge.py @@ -61,6 +61,10 @@ def __str__(self): return res def __eq__(self, rhs): + # Type checking + if not isinstance(rhs, Edge): + return False + # Quick positive check, if both IDs are set. if self.id is not None and rhs.id is not None and self.id == rhs.id: return True diff --git a/redis/commands/graph/node.py b/redis/commands/graph/node.py index 0ebe510ada..4546a393b1 100644 --- a/redis/commands/graph/node.py +++ b/redis/commands/graph/node.py @@ -65,6 +65,10 @@ def __str__(self): return res def __eq__(self, rhs): + # Type checking + if not isinstance(rhs, Node): + return False + # Quick positive check, if both IDs are set. if self.id is not None and rhs.id is not None and self.id != rhs.id: return False diff --git a/redis/commands/graph/path.py b/redis/commands/graph/path.py index 6f2214a3b5..ee22dc8c6b 100644 --- a/redis/commands/graph/path.py +++ b/redis/commands/graph/path.py @@ -54,6 +54,10 @@ def add_edge(self, edge): return self def __eq__(self, other): + # Type checking + if not isinstance(other, Path): + return False + return self.nodes() == other.nodes() and self.edges() == other.edges() def __str__(self):