From 0f8f5444bc3511d671d765540686f23c50c36c0c Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Sat, 24 May 2025 14:44:32 -0700 Subject: [PATCH] Lint --- libs/langgraph/langgraph/pregel/io.py | 28 ++++------------------- libs/langgraph/tests/test_pregel_async.py | 5 +--- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/libs/langgraph/langgraph/pregel/io.py b/libs/langgraph/langgraph/pregel/io.py index 53fe7ef7f..7b2578dce 100644 --- a/libs/langgraph/langgraph/pregel/io.py +++ b/libs/langgraph/langgraph/pregel/io.py @@ -2,8 +2,6 @@ from collections import Counter from collections.abc import Iterator, Mapping, Sequence from typing import Any, Literal, Optional, TypeVar, Union -from langchain_core.runnables.utils import AddableDict - from langgraph.channels.base import BaseChannel, EmptyChannelError from langgraph.constants import ( EMPTY_SEQ, @@ -99,14 +97,6 @@ def map_input( logger.warning(f"Input channel {k} not found in {input_channels}") -class AddableValuesDict(AddableDict): - def __add__(self, other: dict[str, Any]) -> "AddableValuesDict": - return self | other - - def __radd__(self, other: dict[str, Any]) -> "AddableValuesDict": - return other | self - - def map_output_values( output_channels: Union[str, Sequence[str]], pending_writes: Union[Literal[True], Sequence[tuple[str, Any]]], @@ -122,15 +112,7 @@ def map_output_values( if pending_writes is True or { c for c, _ in pending_writes if c in output_channels }: - yield AddableValuesDict(read_channels(channels, output_channels)) - - -class AddableUpdatesDict(AddableDict): - def __add__(self, other: dict[str, Any]) -> "AddableUpdatesDict": - return [self, other] - - def __radd__(self, other: dict[str, Any]) -> "AddableUpdatesDict": - raise TypeError("AddableUpdatesDict does not support right-side addition") + yield read_channels(channels, output_channels) def map_output_updates( @@ -179,17 +161,17 @@ def map_output_updates( }, ) ) - grouped: dict[str, list[Any]] = {t.name: [] for t, _ in output_tasks} + grouped: dict[str, Any] = {t.name: [] for t, _ in output_tasks} for node, value in updated: grouped[node].append(value) for node, value in grouped.items(): if len(value) == 0: - grouped[node] = None # type: ignore[assignment] + grouped[node] = None if len(value) == 1: grouped[node] = value[0] if cached: - grouped["__metadata__"] = {"cached": cached} # type: ignore[assignment] - yield AddableUpdatesDict(grouped) + grouped["__metadata__"] = {"cached": cached} + yield grouped T = TypeVar("T") diff --git a/libs/langgraph/tests/test_pregel_async.py b/libs/langgraph/tests/test_pregel_async.py index 5756d6183..0b64ebda4 100644 --- a/libs/langgraph/tests/test_pregel_async.py +++ b/libs/langgraph/tests/test_pregel_async.py @@ -5456,10 +5456,7 @@ async def test_nested_graph(snapshot: SnapshotAssertion) -> None: if event["event"] == "on_chain_end" and event["run_id"] == str(UUID(int=0)): times_called += 1 assert event["data"] == { - "output": [ - {"inner": {"my_key": "my value there"}}, - {"side": {"my_key": "my value there and back again"}}, - ] + "output": {"side": {"my_key": "my value there and back again"}} } assert times_called == 1