From 220314b53a960964a82657451b846f3a7cb2f348 Mon Sep 17 00:00:00 2001 From: Sydney Runkle <54324534+sydney-runkle@users.noreply.github.com> Date: Fri, 1 Aug 2025 10:33:46 -0400 Subject: [PATCH] fix(langgraph): fix up deprecation warnings (#5796) Fixes https://github.com/langchain-ai/langgraph/issues/5795 * Must use `category=None` on decorator so that we get type checking support but no dupe warning * Fixed tuple on `confix_type` warning causing false warning --- libs/langgraph/langgraph/errors.py | 2 +- libs/langgraph/langgraph/pregel/main.py | 9 +++++---- libs/langgraph/langgraph/types.py | 5 +---- libs/langgraph/tests/test_deprecation.py | 9 ++++----- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/libs/langgraph/langgraph/errors.py b/libs/langgraph/langgraph/errors.py index 841abbaf7..6e717d284 100644 --- a/libs/langgraph/langgraph/errors.py +++ b/libs/langgraph/langgraph/errors.py @@ -91,7 +91,7 @@ class GraphInterrupt(GraphBubbleUp): @deprecated( "NodeInterrupt is deprecated. Please use `langgraph.types.interrupt` instead.", - stacklevel=2, + category=None, ) class NodeInterrupt(GraphInterrupt): """Raised by a node to interrupt execution. diff --git a/libs/langgraph/langgraph/pregel/main.py b/libs/langgraph/langgraph/pregel/main.py index 87f64bebc..37bd069c2 100644 --- a/libs/langgraph/langgraph/pregel/main.py +++ b/libs/langgraph/langgraph/pregel/main.py @@ -637,8 +637,7 @@ class Pregel( **deprecated_kwargs: Unpack[DeprecatedKwargs], ) -> None: if ( - config_type := deprecated_kwargs.get("config_type"), - MISSING, + config_type := deprecated_kwargs.get("config_type", MISSING) ) is not MISSING: warnings.warn( "`config_type` is deprecated and will be removed. Please use `context_schema` instead.", @@ -785,7 +784,8 @@ class Pregel( return self @deprecated( - "`config_schema` is deprecated. Use `get_context_jsonschema` for the relevant schema instead." + "`config_schema` is deprecated. Use `get_context_jsonschema` for the relevant schema instead.", + category=None, ) def config_schema(self, *, include: Sequence[str] | None = None) -> type[BaseModel]: warnings.warn( @@ -810,7 +810,8 @@ class Pregel( return create_model(self.get_name("Config"), field_definitions=fields) @deprecated( - "`get_config_jsonschema` is deprecated. Use `get_context_jsonschema` instead." + "`get_config_jsonschema` is deprecated. Use `get_context_jsonschema` instead.", + category=None, ) def get_config_jsonschema( self, *, include: Sequence[str] | None = None diff --git a/libs/langgraph/langgraph/types.py b/libs/langgraph/langgraph/types.py index 3dcc8f8dc..5fbc304b7 100644 --- a/libs/langgraph/langgraph/types.py +++ b/libs/langgraph/langgraph/types.py @@ -191,10 +191,7 @@ class Interrupt: return cls(value=value, id=xxh3_128_hexdigest(ns.encode())) @property - @deprecated( - "`interrupt_id` is deprecated. Use `id` instead.", - stacklevel=2, - ) + @deprecated("`interrupt_id` is deprecated. Use `id` instead.", category=None) def interrupt_id(self) -> str: warn( "`interrupt_id` is deprecated. Use `id` instead.", diff --git a/libs/langgraph/tests/test_deprecation.py b/libs/langgraph/tests/test_deprecation.py index 01ab10d2e..b8483327e 100644 --- a/libs/langgraph/tests/test_deprecation.py +++ b/libs/langgraph/tests/test_deprecation.py @@ -95,8 +95,6 @@ def test_pregel_types_deprecation() -> None: from langgraph.pregel.types import StateSnapshot # noqa: F401 -@pytest.mark.filterwarnings("ignore:`config_schema` is deprecated") -@pytest.mark.filterwarnings("ignore:`get_config_jsonschema` is deprecated") def test_config_schema_deprecation() -> None: with pytest.warns( LangGraphDeprecatedSinceV10, @@ -122,7 +120,6 @@ def test_config_schema_deprecation() -> None: graph.get_config_jsonschema() -@pytest.mark.filterwarnings("ignore:`config_schema` is deprecated") def test_config_schema_deprecation_on_entrypoint() -> None: with pytest.warns( LangGraphDeprecatedSinceV10, @@ -133,6 +130,10 @@ def test_config_schema_deprecation_on_entrypoint() -> None: def my_entrypoint(state: PlainState) -> PlainState: return state + with pytest.warns( + LangGraphDeprecatedSinceV10, + match="`config_schema` is deprecated. Use `get_context_jsonschema` for the relevant schema instead.", + ): assert my_entrypoint.context_schema == PlainState assert my_entrypoint.config_schema() is not None @@ -161,7 +162,6 @@ def test_config_type_deprecation_pregel(mocker: MockerFixture) -> None: assert instance.context_schema == PlainState -@pytest.mark.filterwarnings("ignore:`interrupt_id` is deprecated. Use `id` instead.") def test_interrupt_attributes_deprecation() -> None: interrupt = Interrupt(value="question", id="abc") @@ -172,7 +172,6 @@ def test_interrupt_attributes_deprecation() -> None: interrupt.interrupt_id -@pytest.mark.filterwarnings("ignore:NodeInterrupt is deprecated.") def test_node_interrupt_deprecation() -> None: with pytest.warns( LangGraphDeprecatedSinceV10,