mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-08-21 07:02:25 +02:00
fix(checkpoint/serde): use lazy isinstance check for DiffDelta
Replace duck-typing check with lazy import inside _is_diff_delta helper function to avoid module-level circular dependency while using proper isinstance semantics. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
99bc8bb9af
commit
ded1dbba2f
@@ -64,6 +64,11 @@ def _warn_once(
|
||||
logger.warning(msg, *args)
|
||||
|
||||
|
||||
def _is_diff_delta(obj: Any) -> bool:
|
||||
from langgraph.checkpoint.base import DiffDelta # lazy import avoids circular dep
|
||||
return isinstance(obj, DiffDelta)
|
||||
|
||||
|
||||
class JsonPlusSerializer(SerializerProtocol):
|
||||
"""Serializer that uses ormsgpack, with optional fallbacks.
|
||||
|
||||
@@ -256,11 +261,7 @@ class JsonPlusSerializer(SerializerProtocol):
|
||||
return "bytes", obj
|
||||
elif isinstance(obj, bytearray):
|
||||
return "bytearray", obj
|
||||
elif (
|
||||
type(obj).__name__ == "DiffDelta"
|
||||
and hasattr(obj, "delta")
|
||||
and hasattr(obj, "prev_version")
|
||||
):
|
||||
elif _is_diff_delta(obj):
|
||||
return "diff", _msgpack_enc({"d": obj.delta, "p": obj.prev_version})
|
||||
else:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user