diff --git a/libs/checkpoint/langgraph/checkpoint/memory/__init__.py b/libs/checkpoint/langgraph/checkpoint/memory/__init__.py index dd8e86834..26a8f19b0 100644 --- a/libs/checkpoint/langgraph/checkpoint/memory/__init__.py +++ b/libs/checkpoint/langgraph/checkpoint/memory/__init__.py @@ -77,11 +77,9 @@ def __init__( self.storage = factory(lambda: defaultdict(dict)) self.writes = factory(dict) self.stack = ExitStack() - try: + if factory is not defaultdict: self.stack.enter_context(self.storage) # type: ignore[arg-type] self.stack.enter_context(self.writes) # type: ignore[arg-type] - except (TypeError, AttributeError): - pass def __enter__(self) -> "MemorySaver": return self.stack.__enter__()