From c1371693257f2fe4478a214d4a8781405e5fb6aa Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Mon, 16 Jun 2025 12:57:46 -0700 Subject: [PATCH] Preparation for 0.5 release - Update deprecation warnings to mention 0.5, no 1.0 - Add back type hint support for Runnable arg to add_node --- libs/langgraph/langgraph/func/__init__.py | 6 +++--- libs/langgraph/langgraph/graph/state.py | 13 +++++++------ libs/langgraph/langgraph/warnings.py | 6 +++--- libs/langgraph/tests/test_deprecation.py | 14 +++++++------- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/libs/langgraph/langgraph/func/__init__.py b/libs/langgraph/langgraph/func/__init__.py index 2b3095b23..ba0b3c4cb 100644 --- a/libs/langgraph/langgraph/func/__init__.py +++ b/libs/langgraph/langgraph/func/__init__.py @@ -38,7 +38,7 @@ from langgraph.pregel.read import PregelNode from langgraph.pregel.write import ChannelWrite, ChannelWriteEntry from langgraph.store.base import BaseStore from langgraph.types import _DC_KWARGS, CachePolicy, RetryPolicy, StreamMode -from langgraph.warnings import LangGraphDeprecatedSinceV10 +from langgraph.warnings import LangGraphDeprecatedSinceV05 class TaskFunction(Generic[P, T]): @@ -179,7 +179,7 @@ def task( if (retry := kwargs.get("retry", UNSET)) is not UNSET: warnings.warn( "`retry` is deprecated and will be removed. Please use `retry_policy` instead.", - category=LangGraphDeprecatedSinceV10, + category=LangGraphDeprecatedSinceV05, ) if retry_policy is None: retry_policy = retry # type: ignore[assignment] @@ -383,7 +383,7 @@ class entrypoint: if (retry := kwargs.get("retry", UNSET)) is not UNSET: warnings.warn( "`retry` is deprecated and will be removed. Please use `retry_policy` instead.", - category=LangGraphDeprecatedSinceV10, + category=LangGraphDeprecatedSinceV05, ) if retry_policy is None: retry_policy = retry # type: ignore[assignment] diff --git a/libs/langgraph/langgraph/graph/state.py b/libs/langgraph/langgraph/graph/state.py index 7081402c7..151b1b278 100644 --- a/libs/langgraph/langgraph/graph/state.py +++ b/libs/langgraph/langgraph/graph/state.py @@ -86,7 +86,7 @@ from langgraph.utils.fields import ( ) from langgraph.utils.pydantic import create_model from langgraph.utils.runnable import coerce_to_runnable -from langgraph.warnings import LangGraphDeprecatedSinceV10 +from langgraph.warnings import LangGraphDeprecatedSinceV05 logger = logging.getLogger(__name__) @@ -160,6 +160,7 @@ StateNode: TypeAlias = Union[ _NodeWithConfigWriter[StateT_contra], _NodeWithConfigStore[StateT_contra], _NodeWithConfigWriterStore[StateT_contra], + Runnable[StateT_contra, Any], ] @@ -261,7 +262,7 @@ class StateGraph(Generic[StateT, InputT, OutputT]): if (input_ := kwargs.get("input", UNSET)) is not UNSET: warnings.warn( "`input` is deprecated and will be removed. Please use `input_schema` instead.", - category=LangGraphDeprecatedSinceV10, + category=LangGraphDeprecatedSinceV05, stacklevel=2, ) if input_schema is None: @@ -270,7 +271,7 @@ class StateGraph(Generic[StateT, InputT, OutputT]): if (output := kwargs.get("output", UNSET)) is not UNSET: warnings.warn( "`output` is deprecated and will be removed. Please use `output_schema` instead.", - category=LangGraphDeprecatedSinceV10, + category=LangGraphDeprecatedSinceV05, stacklevel=2, ) if output_schema is None: @@ -436,7 +437,7 @@ class StateGraph(Generic[StateT, InputT, OutputT]): if (retry := kwargs.get("retry", UNSET)) is not UNSET: warnings.warn( "`retry` is deprecated and will be removed. Please use `retry_policy` instead.", - category=LangGraphDeprecatedSinceV10, + category=LangGraphDeprecatedSinceV05, ) if retry_policy is None: retry_policy = retry # type: ignore[assignment] @@ -444,7 +445,7 @@ class StateGraph(Generic[StateT, InputT, OutputT]): if (input_ := kwargs.get("input", UNSET)) is not UNSET: warnings.warn( "`input` is deprecated and will be removed. Please use `input_schema` instead.", - category=LangGraphDeprecatedSinceV10, + category=LangGraphDeprecatedSinceV05, ) if input_schema is None: input_schema = cast(Union[type[InputT], None], input_) @@ -535,7 +536,7 @@ class StateGraph(Generic[StateT, InputT, OutputT]): if input_schema is not None: self._add_schema(input_schema) self.nodes[node] = StateNodeSpec( - coerce_to_runnable(action, name=node, trace=False), # type: ignore + coerce_to_runnable(action, name=node, trace=False), metadata, input=input_schema or self.state_schema, retry_policy=retry_policy, diff --git a/libs/langgraph/langgraph/warnings.py b/libs/langgraph/langgraph/warnings.py index 00a5dea5a..e8fd59d88 100644 --- a/libs/langgraph/langgraph/warnings.py +++ b/libs/langgraph/langgraph/warnings.py @@ -41,8 +41,8 @@ class LangGraphDeprecationWarning(DeprecationWarning): return message -class LangGraphDeprecatedSinceV10(LangGraphDeprecationWarning): - """A specific `LangGraphDeprecationWarning` subclass defining functionality deprecated since LangGraph v1.0.0""" +class LangGraphDeprecatedSinceV05(LangGraphDeprecationWarning): + """A specific `LangGraphDeprecationWarning` subclass defining functionality deprecated since LangGraph v0.5.0""" def __init__(self, message: str, *args: object) -> None: - super().__init__(message, *args, since=(1, 0), expected_removal=(2, 0)) + super().__init__(message, *args, since=(0, 5), expected_removal=(2, 0)) diff --git a/libs/langgraph/tests/test_deprecation.py b/libs/langgraph/tests/test_deprecation.py index 456961390..2a217edae 100644 --- a/libs/langgraph/tests/test_deprecation.py +++ b/libs/langgraph/tests/test_deprecation.py @@ -4,7 +4,7 @@ from typing_extensions import TypedDict from langgraph.func import entrypoint, task from langgraph.graph import StateGraph from langgraph.types import RetryPolicy -from langgraph.warnings import LangGraphDeprecatedSinceV10 +from langgraph.warnings import LangGraphDeprecatedSinceV05 class PlainState(TypedDict): ... @@ -14,7 +14,7 @@ def test_add_node_retry_arg() -> None: builder = StateGraph(PlainState) with pytest.warns( - LangGraphDeprecatedSinceV10, + LangGraphDeprecatedSinceV05, match="`retry` is deprecated and will be removed. Please use `retry_policy` instead.", ): builder.add_node("test_node", lambda state: state, retry=RetryPolicy()) # type: ignore[arg-type] @@ -22,7 +22,7 @@ def test_add_node_retry_arg() -> None: def test_task_retry_arg() -> None: with pytest.warns( - LangGraphDeprecatedSinceV10, + LangGraphDeprecatedSinceV05, match="`retry` is deprecated and will be removed. Please use `retry_policy` instead.", ): @@ -33,7 +33,7 @@ def test_task_retry_arg() -> None: def test_entrypoint_retry_arg() -> None: with pytest.warns( - LangGraphDeprecatedSinceV10, + LangGraphDeprecatedSinceV05, match="`retry` is deprecated and will be removed. Please use `retry_policy` instead.", ): @@ -44,7 +44,7 @@ def test_entrypoint_retry_arg() -> None: def test_state_graph_input_schema() -> None: with pytest.warns( - LangGraphDeprecatedSinceV10, + LangGraphDeprecatedSinceV05, match="`input` is deprecated and will be removed. Please use `input_schema` instead.", ): StateGraph(PlainState, input=PlainState) # type: ignore[arg-type] @@ -52,7 +52,7 @@ def test_state_graph_input_schema() -> None: def test_state_graph_output_schema() -> None: with pytest.warns( - LangGraphDeprecatedSinceV10, + LangGraphDeprecatedSinceV05, match="`output` is deprecated and will be removed. Please use `output_schema` instead.", ): StateGraph(PlainState, output=PlainState) # type: ignore[arg-type] @@ -62,7 +62,7 @@ def test_add_node_input_schema() -> None: builder = StateGraph(PlainState) with pytest.warns( - LangGraphDeprecatedSinceV10, + LangGraphDeprecatedSinceV05, match="`input` is deprecated and will be removed. Please use `input_schema` instead.", ): builder.add_node("test_node", lambda state: state, input=PlainState) # type: ignore[arg-type]