From 0f83d9fafe8d0ce490caea83dd8dd68d97bcf656 Mon Sep 17 00:00:00 2001 From: Mason Daugherty Date: Fri, 7 Nov 2025 07:47:29 -0500 Subject: [PATCH] style: update docstrings to reference `StateGraph` (#6308) nit --- libs/langgraph/langgraph/graph/state.py | 20 ++++++++++---------- libs/langgraph/langgraph/typing.py | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libs/langgraph/langgraph/graph/state.py b/libs/langgraph/langgraph/graph/state.py index 84f0ea8f2..7a3d11a32 100644 --- a/libs/langgraph/langgraph/graph/state.py +++ b/libs/langgraph/langgraph/graph/state.py @@ -289,7 +289,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]): destinations: dict[str, str] | tuple[str, ...] | None = None, **kwargs: Unpack[DeprecatedKwargs], ) -> Self: - """Add a new node to the state graph, input schema is inferred as the state schema. + """Add a new node to the `StateGraph`, input schema is inferred as the state schema. Will take the name of the function/runnable as the node name. """ ... @@ -307,7 +307,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]): destinations: dict[str, str] | tuple[str, ...] | None = None, **kwargs: Unpack[DeprecatedKwargs], ) -> Self: - """Add a new node to the state graph, input schema is specified. + """Add a new node to the `StateGraph`, input schema is specified. Will take the name of the function/runnable as the node name. """ ... @@ -326,7 +326,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]): destinations: dict[str, str] | tuple[str, ...] | None = None, **kwargs: Unpack[DeprecatedKwargs], ) -> Self: - """Add a new node to the state graph, input schema is inferred as the state schema.""" + """Add a new node to the `StateGraph`, input schema is inferred as the state schema.""" ... @overload @@ -343,7 +343,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]): destinations: dict[str, str] | tuple[str, ...] | None = None, **kwargs: Unpack[DeprecatedKwargs], ) -> Self: - """Add a new node to the state graph, input schema is specified.""" + """Add a new node to the `StateGraph`, input schema is specified.""" ... def add_node( @@ -359,7 +359,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]): destinations: dict[str, str] | tuple[str, ...] | None = None, **kwargs: Unpack[DeprecatedKwargs], ) -> Self: - """Add a new node to the state graph. + """Add a new node to the `StateGraph`. Args: node: The function or runnable this node will run. @@ -416,7 +416,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]): ``` Returns: - Self: The instance of the state graph, allowing for method chaining. + Self: The instance of the `StateGraph`, allowing for method chaining. """ if (retry := kwargs.get("retry", MISSING)) is not MISSING: warnings.warn( @@ -571,7 +571,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]): ValueError: If the start key is `'END'` or if the start key or end key is not present in the graph. Returns: - Self: The instance of the state graph, allowing for method chaining. + Self: The instance of the `StateGraph`, allowing for method chaining. """ if self.compiled: logger.warning( @@ -676,7 +676,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]): ValueError: If the sequence contains duplicate node names. Returns: - Self: The instance of the state graph, allowing for method chaining. + Self: The instance of the `StateGraph`, allowing for method chaining. """ if len(nodes) < 1: raise ValueError("Sequence requires at least one node.") @@ -809,7 +809,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]): debug: bool = False, name: str | None = None, ) -> CompiledStateGraph[StateT, ContextT, InputT, OutputT]: - """Compiles the state graph into a `CompiledStateGraph` object. + """Compiles the `StateGraph` into a `CompiledStateGraph` object. The compiled graph implements the `Runnable` interface and can be invoked, streamed, batched, and run asynchronously. @@ -826,7 +826,7 @@ class StateGraph(Generic[StateT, ContextT, InputT, OutputT]): name: The name to use for the compiled graph. Returns: - CompiledStateGraph: The compiled state graph. + CompiledStateGraph: The compiled `StateGraph`. """ # assign default values interrupt_before = interrupt_before or [] diff --git a/libs/langgraph/langgraph/typing.py b/libs/langgraph/langgraph/typing.py index 513e11fd5..c1187357b 100644 --- a/libs/langgraph/langgraph/typing.py +++ b/libs/langgraph/langgraph/typing.py @@ -31,13 +31,13 @@ ContextT_contra = TypeVar( ) InputT = TypeVar("InputT", bound=StateLike, default=StateT) -"""Type variable used to represent the input to a state graph. +"""Type variable used to represent the input to a `StateGraph`. Defaults to `StateT`. """ OutputT = TypeVar("OutputT", bound=StateLike, default=StateT) -"""Type variable used to represent the output of a state graph. +"""Type variable used to represent the output of a `StateGraph`. Defaults to `StateT`. """