Skip to content

Commit 3580d7d

Browse files
committed
narrowed down runtime check of type Next
1 parent 0c2bfc0 commit 3580d7d

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/edgygraph/graph/types.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ class Types[T: StateProtocol, S: SharedProtocol]:
3636
def is_next(cls, x: Any) -> TypeGuard[Next[T, S]]:
3737
return (
3838
cls.is_resolved_next(x) or
39-
callable(x)
39+
(callable(x) and not (
40+
cls.is_any_source(x) or
41+
cls.is_resolved_next(x) or
42+
x is END
43+
))
4044
)
4145

4246
@classmethod

src/edgygraph/nodes.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
from __future__ import annotations
12
from abc import ABC, abstractmethod
3+
from copy import copy
24

35
from .states import StateProtocol, SharedProtocol
46

@@ -33,6 +35,19 @@ async def __call__(self, state: T, shared: S) -> None:
3335
"""
3436
pass
3537

38+
39+
def copy(self) -> Node[T, S]:
40+
"""
41+
Creates a copy of the node. This can be used when the same node is used multiple times in the graph.
42+
43+
Args:
44+
node: The node to copy.
45+
46+
Returns:
47+
A copy of the node.
48+
"""
49+
return copy(self)
50+
3651

3752

3853
class START:

0 commit comments

Comments
 (0)