Skip to content

Commit c8d8304

Browse files
committed
🐛 fix has_node throwing instead of False return.
closes #38
1 parent 5b2ec7d commit c8d8304

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pynode_next/graph.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ def remove_edge(self, nodeA, nodeB, directed: bool = False):
134134

135135
def has_node(self, node):
136136
"""Checks if a node exists in the graph."""
137-
return self.node(node) is not None
137+
try:
138+
self.node(node)
139+
return True
140+
except NodeDoesntExistError:
141+
return False
138142

139143
def add_all(self, elements: Iterable[Union[Node, Edge]]):
140144
"""Adds all node and edge objects from an iterable. all elements need to be of the type `Node` or `Edge`"""

0 commit comments

Comments
 (0)