Checked other resources
Related Issues / PRs
No response
Reproduction Steps / Example Code (Python)
from typing import TypedDict
from langgraph.store.memory import InMemoryStore
class Prefs(TypedDict):
theme: str
store = InMemoryStore()
value: Prefs = {"theme": "dark"}
store.put(("users", "123"), "prefs", value)
Error Message and Stack Trace (if applicable)
repro.py:9: error: Argument 3 to "put" of "BaseStore" has incompatible type "Prefs"; expected "dict[str, Any]" [arg-type]
Found 1 error in 1 file (checked 1 source file)
Description
- I'm trying to use the
langgraph library's Store.put()/aput() to store a TypedDict value (a well-typed, string-keyed mapping matching the store's own requirements).
- I expect the call to type-check cleanly with mypy, since a
TypedDict is exactly the kind of typed, JSON-serializable payload the store expects.
- Instead, mypy rejects it with the error shown below, because
value is typed as dict[str, Any], which requires full mutability (arbitrary keys can be added/removed/overwritten) that a TypedDict doesn't support. This breaks type-checking in CI for any caller passing a TypedDict to store.put()/aput(), despite the code working correctly at runtime.
Proposed fix: widen the value parameter on BaseStore.put()/aput() (and PutOp.value) from dict[str, Any] to collections.abc.Mapping[str, Any]. This is a compatible widening (plain dicts still satisfy Mapping[str, Any]) so it doesn't change behavior or break existing callers.
System Info
langgraph-checkpoint: 4.2.0
Python 3.14.5, Darwin
Checked other resources
Related Issues / PRs
No response
Reproduction Steps / Example Code (Python)
Error Message and Stack Trace (if applicable)
Description
langgraphlibrary'sStore.put()/aput()to store aTypedDictvalue (a well-typed, string-keyed mapping matching the store's own requirements).TypedDictis exactly the kind of typed, JSON-serializable payload the store expects.valueis typed asdict[str, Any], which requires full mutability (arbitrary keys can be added/removed/overwritten) that aTypedDictdoesn't support. This breaks type-checking in CI for any caller passing aTypedDicttostore.put()/aput(), despite the code working correctly at runtime.Proposed fix: widen the
valueparameter onBaseStore.put()/aput()(andPutOp.value) fromdict[str, Any]tocollections.abc.Mapping[str, Any]. This is a compatible widening (plain dicts still satisfyMapping[str, Any]) so it doesn't change behavior or break existing callers.System Info
langgraph-checkpoint: 4.2.0
Python 3.14.5, Darwin