chore: apply ruff format/lint fixes

This commit is contained in:
Sydney Runkle
2026-05-06 15:03:13 -04:00
parent 6c43a254ef
commit e8c6d9cc31
2 changed files with 23 additions and 4 deletions
+8 -2
View File
@@ -286,12 +286,18 @@ def _messages_delta_reducer(
else:
state_msgs = cast(
"list[AnyMessage]",
[message_chunk_to_message(cast(BaseMessageChunk, m)) for m in convert_to_messages(state)],
[
message_chunk_to_message(cast(BaseMessageChunk, m))
for m in convert_to_messages(state)
],
)
# Coerce chunks to full messages — streaming nodes can emit BaseMessageChunk.
msgs = cast(
"list[AnyMessage]",
[message_chunk_to_message(cast(BaseMessageChunk, m)) for m in convert_to_messages(flat)],
[
message_chunk_to_message(cast(BaseMessageChunk, m))
for m in convert_to_messages(flat)
],
)
# REMOVE_ALL_MESSAGES resets everything; find the last sentinel and
+15 -2
View File
@@ -3,7 +3,12 @@ from collections.abc import Sequence
from typing import Annotated
import pytest
from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessage, RemoveMessage
from langchain_core.messages import (
AIMessage,
AIMessageChunk,
HumanMessage,
RemoveMessage,
)
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.checkpoint.serde.types import _DeltaSnapshot
from typing_extensions import NotRequired, TypedDict
@@ -311,7 +316,15 @@ def test_messages_delta_reducer_remove_all_messages() -> None:
state = [HumanMessage(content="old", id="h1"), AIMessage(content="prior", id="a1")]
# Sentinel mid-batch: everything before it (including state) is discarded.
result = _messages_delta_reducer(state, [[RemoveMessage(id=REMOVE_ALL_MESSAGES), HumanMessage(content="fresh", id="h2")]])
result = _messages_delta_reducer(
state,
[
[
RemoveMessage(id=REMOVE_ALL_MESSAGES),
HumanMessage(content="fresh", id="h2"),
]
],
)
assert len(result) == 1
assert result[0].content == "fresh"