mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-11 12:17:53 +02:00
Remove if/else
This commit is contained in:
@@ -219,9 +219,9 @@ class NodeBuilder:
|
||||
*channels: str,
|
||||
) -> Self:
|
||||
"""Adds the specified channels to read from, without subscribing to them."""
|
||||
assert isinstance(self._channels, list), (
|
||||
"Cannot read additional channels when subscribed to single channels"
|
||||
)
|
||||
assert isinstance(
|
||||
self._channels, list
|
||||
), "Cannot read additional channels when subscribed to single channels"
|
||||
self._channels.extend(channels)
|
||||
return self
|
||||
|
||||
@@ -1559,12 +1559,8 @@ class Pregel(PregelProtocol[StateT, InputT, OutputT], Generic[StateT, InputT, Ou
|
||||
# copy checkpoint
|
||||
next_config = checkpointer.put(
|
||||
saved.parent_config
|
||||
or (
|
||||
patch_configurable(
|
||||
saved.config, {CONFIG_KEY_CHECKPOINT_ID: None}
|
||||
)
|
||||
if isinstance(values, list) and len(values) > 0
|
||||
else saved.config
|
||||
or patch_configurable(
|
||||
saved.config, {CONFIG_KEY_CHECKPOINT_ID: None}
|
||||
),
|
||||
next_checkpoint,
|
||||
{
|
||||
@@ -2021,12 +2017,8 @@ class Pregel(PregelProtocol[StateT, InputT, OutputT], Generic[StateT, InputT, Ou
|
||||
# copy checkpoint
|
||||
next_config = await checkpointer.aput(
|
||||
saved.parent_config
|
||||
or (
|
||||
patch_configurable(
|
||||
saved.config, {CONFIG_KEY_CHECKPOINT_ID: None}
|
||||
)
|
||||
if isinstance(values, list) and len(values) > 0
|
||||
else saved.config
|
||||
or patch_configurable(
|
||||
saved.config, {CONFIG_KEY_CHECKPOINT_ID: None}
|
||||
),
|
||||
next_checkpoint,
|
||||
{
|
||||
|
||||
@@ -4301,7 +4301,7 @@ def test_dynamic_interrupt(sync_checkpointer: BaseCheckpointSaver) -> None:
|
||||
)
|
||||
|
||||
|
||||
def test_copy_checkpoint(sync_checkpointer: BaseCheckpointSaver) -> None:
|
||||
def test_clear_tasks_checkpoint(sync_checkpointer: BaseCheckpointSaver) -> None:
|
||||
class State(TypedDict):
|
||||
my_key: Annotated[str, operator.add]
|
||||
market: str
|
||||
@@ -4450,7 +4450,8 @@ def test_copy_checkpoint(sync_checkpointer: BaseCheckpointSaver) -> None:
|
||||
)
|
||||
|
||||
# clear the interrupt and next tasks
|
||||
tool_two.update_state(thread1, None, as_node="__copy__")
|
||||
tool_two.update_state(thread1, None)
|
||||
|
||||
# interrupt is cleared, next task is kept
|
||||
assert tool_two.get_state(thread1) == StateSnapshot(
|
||||
values={"my_key": "value ⛰️", "market": "DE"},
|
||||
@@ -4481,7 +4482,7 @@ def test_copy_checkpoint(sync_checkpointer: BaseCheckpointSaver) -> None:
|
||||
created_at=AnyStr(),
|
||||
metadata={
|
||||
"parents": {},
|
||||
"source": "fork",
|
||||
"source": "update",
|
||||
"step": 1,
|
||||
},
|
||||
parent_config=([*tool_two.checkpointer.list(thread1, limit=2)][-1].config),
|
||||
|
||||
Reference in New Issue
Block a user