From e8c6d9cc319d49a9cb0fb66556902af886eae61a Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Wed, 6 May 2026 15:03:13 -0400 Subject: [PATCH] chore: apply ruff format/lint fixes --- libs/langgraph/langgraph/graph/message.py | 10 ++++++++-- libs/langgraph/tests/test_channels.py | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/libs/langgraph/langgraph/graph/message.py b/libs/langgraph/langgraph/graph/message.py index 0e0bc3c7a..091613e77 100644 --- a/libs/langgraph/langgraph/graph/message.py +++ b/libs/langgraph/langgraph/graph/message.py @@ -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 diff --git a/libs/langgraph/tests/test_channels.py b/libs/langgraph/tests/test_channels.py index 8c6ccb842..1ad002411 100644 --- a/libs/langgraph/tests/test_channels.py +++ b/libs/langgraph/tests/test_channels.py @@ -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"