mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-11 12:17:53 +02:00
chore: apply ruff format/lint fixes
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user