style(langgraph): format lint

This commit is contained in:
Caspar Broekhuizen
2025-10-09 14:33:30 -07:00
parent b4549b436f
commit 7dba4f6791
2 changed files with 13 additions and 18 deletions
+7 -5
View File
@@ -316,9 +316,7 @@ class PregelLoop:
]
writes_to_save: WritesT = [
w[1:] for w in self.checkpoint_pending_writes if w[0] == task_id
] + [
(c, v) for c, v in writes if c != RESUME
]
] + [(c, v) for c, v in writes if c != RESUME]
self.checkpoint_pending_writes.extend((task_id, c, v) for c, v in writes)
else:
# build map of existing interrupts for this task for quick lookup
@@ -331,7 +329,7 @@ class PregelLoop:
for ch, v in writes:
if ch == INTERRUPT:
# we merge new interrupt writes with existing interrupts writes if they
# occured within the same task (which means they have the same interrupt id)
# occurred within the same task (which means they have the same interrupt id)
new_interrupts = v if isinstance(v, list) else list(v)
if new_interrupts and (
existing := existing_interrupts_by_id.get(new_interrupts[0].id)
@@ -339,7 +337,11 @@ class PregelLoop:
# if the graph is invoked with None, we will hit the same interrupt
# that was raised before, in this case we don't want to duplicate its write
# so we just keep the existing checkpoint writes
v = existing + new_interrupts if self.input is not None else existing
v = (
existing + new_interrupts
if self.input is not None
else existing
)
writes_to_save.append((ch, v))
else:
# we add non-interrupt writes as-is
+6 -13
View File
@@ -583,6 +583,7 @@ async def test_node_with_multiple_interrupts_requires_full_resume_async(
assert final_result["input"] == "human_first-human_second-human_third"
assert node_counter == 5
def test_invoke_interrupted_graph_with_none(
sync_checkpointer: BaseCheckpointSaver,
) -> None:
@@ -617,9 +618,7 @@ def test_invoke_interrupted_graph_with_none(
# invoke with None. this should execute the node and the history should
# look the same as the first run
partial = graph.invoke(
None, config=config
)
partial = graph.invoke(None, config=config)
second_history = list(graph.get_state_history(config))
remaining_interrupts = partial.get("__interrupt__", [])
assert len(remaining_interrupts) == 1
@@ -635,21 +634,17 @@ def test_invoke_interrupted_graph_with_none(
assert first_history[0].tasks == second_history[0].tasks
# now resume the first interrupt with some value
partial = graph.invoke(
Command(resume="weet"), config=config
)
partial = graph.invoke(Command(resume="weet"), config=config)
print("partial 3", partial)
third_history = list(graph.get_state_history(config))
remaining_interrupts = partial.get("__interrupt__", [])
assert len(remaining_interrupts) == 1
assert remaining_interrupts[0].value == "second"
assert node_counter == 3
# invoke with None again. the history should look the same as
# the third run
partial = graph.invoke(
None, config=config
)
partial = graph.invoke(None, config=config)
print("partial 4", partial)
fourth_history = list(graph.get_state_history(config))
remaining_interrupts = partial.get("__interrupt__", [])
@@ -664,9 +659,7 @@ def test_invoke_interrupted_graph_with_none(
assert third_history[0].tasks == fourth_history[0].tasks
# resume the graph once more with a real value
partial = graph.invoke(
Command(resume="bix"), config=config
)
partial = graph.invoke(Command(resume="bix"), config=config)
remaining_interrupts = partial.get("__interrupt__", [])
assert len(remaining_interrupts) == 0
assert node_counter == 5