Use casting instead

This commit is contained in:
Tat Dat Duong
2024-10-08 17:08:08 +02:00
parent 50b1a1e230
commit 7e9cf02922
2 changed files with 3 additions and 6 deletions
+1 -1
View File
@@ -390,7 +390,7 @@ class Pregel(Runnable[Union[dict[str, Any], Any], Union[dict[str, Any], Any]]):
continue
# find the subgraph, if any
graph: Optional[Pregel] = find_subgraph_pregel(node.bound)
graph = cast(Optional[Pregel], find_subgraph_pregel(node.bound))
# if found, yield recursively
if graph:
+2 -5
View File
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, Optional
from typing import Optional
from langchain_core.runnables import RunnableLambda, RunnableSequence
from langchain_core.runnables.utils import get_function_nonlocals
@@ -6,9 +6,6 @@ from langchain_core.runnables.utils import get_function_nonlocals
from langgraph.checkpoint.base import ChannelVersions
from langgraph.utils.runnable import Runnable, RunnableCallable, RunnableSeq
if TYPE_CHECKING:
from langgraph.pregel import Pregel
def get_new_channel_versions(
previous_versions: ChannelVersions, current_versions: ChannelVersions
@@ -28,7 +25,7 @@ def get_new_channel_versions(
return new_versions
def find_subgraph_pregel(candidate: Runnable) -> Optional[Pregel]:
def find_subgraph_pregel(candidate: Runnable) -> Optional[Runnable]:
candidates: list[Runnable] = [candidate]
for c in candidates: