Skip to content

Commit de9f142

Browse files
committed
fix(store): add None check for _task in AsyncRedisStore.__aexit__
Fixes type error where _task could be None but was being awaited without proper type guard. Added explicit None check before calling .done() and awaiting the task. Resolves mypy error: Incompatible types in 'await' (actual type 'Task[Any] | None', expected type 'Awaitable[Any]')
1 parent 5a9f966 commit de9f142

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

langgraph/store/redis/aio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ async def __aexit__(
365365
) -> None:
366366
"""Async context manager exit."""
367367
# Cancel the background task created by AsyncBatchedBaseStore
368-
if hasattr(self, "_task") and not self._task.done():
368+
if hasattr(self, "_task") and self._task is not None and not self._task.done():
369369
self._task.cancel()
370370
try:
371371
await self._task

0 commit comments

Comments
 (0)