Skip to content

Commit

Permalink
fix: allow comparing nodes/edges to None
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Feb 10, 2023
1 parent b603f3b commit 821d574
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion arguebuf/model/edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def __init__(
def __post_init__(self):
pass

def __eq__(self, other: Edge) -> bool:
def __eq__(self, other: t.Optional[Edge]) -> bool:
if other is None:
return False

return (
self.id == other.id
and self.source == other.source
Expand Down
3 changes: 3 additions & 0 deletions arguebuf/model/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ def __post_init__(self):
pass

def __eq__(self, other: AbstractNode) -> bool:
if other is None:
return False

return self.id == other.id

def __hash__(self) -> int:
Expand Down

0 comments on commit 821d574

Please sign in to comment.