From 16c09c1bad7af64183891e48e2be8dd9f02533e7 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Wed, 29 Apr 2026 09:34:48 -0400 Subject: [PATCH] refactor(channels): inline _clone_empty into copy and from_checkpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The helper was three lines called from exactly two places — inlining it removes indirection without adding duplication. Co-Authored-By: Claude Sonnet 4.6 (1M context) --- libs/langgraph/langgraph/channels/delta.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libs/langgraph/langgraph/channels/delta.py b/libs/langgraph/langgraph/channels/delta.py index cacfd4d2f..3c73dd010 100644 --- a/libs/langgraph/langgraph/channels/delta.py +++ b/libs/langgraph/langgraph/channels/delta.py @@ -83,14 +83,10 @@ class DeltaChannel(Generic[Value], BaseChannel[Any, Any, Any]): and step % self.snapshot_frequency == 0 ) - def _clone_empty(self) -> Self: + def copy(self) -> Self: new = self.__class__(self.operator, snapshot_frequency=self.snapshot_frequency) new.typ = self.typ # typ may differ from list when set via Annotated injection new.key = self.key # key is injected externally by the graph builder - return new - - def copy(self) -> Self: - new = self._clone_empty() new.value = self.value if self.value is MISSING else _copy.copy(self.value) return new @@ -113,7 +109,9 @@ class DeltaChannel(Generic[Value], BaseChannel[Any, Any, Any]): * `_DeltaSnapshot(value)`: restore value directly from snapshot. * plain value (migration from old BinOp blobs): use directly. """ - new = self._clone_empty() + new = self.__class__(self.operator, snapshot_frequency=self.snapshot_frequency) + new.typ = self.typ # typ may differ from list when set via Annotated injection + new.key = self.key # key is injected externally by the graph builder if checkpoint is MISSING or checkpoint is DELTA_SENTINEL: new.value = _empty(new.typ) elif isinstance(checkpoint, _DeltaSnapshot):