Merge pull request #1771 from langchain-ai/nc/19sep/mypy-langgraph-partial

Enable mypy for langgraph lib
This commit is contained in:
Nuno Campos
2024-09-19 16:53:42 -07:00
committed by GitHub
47 changed files with 593 additions and 401 deletions
@@ -1,6 +1,6 @@
import threading
from contextlib import contextmanager
from typing import Any, Iterator, List, Optional, Union
from typing import Any, Iterator, Optional, Sequence, Union
from langchain_core.runnables import RunnableConfig
from psycopg import Connection, Cursor, Pipeline
@@ -332,7 +332,7 @@ class PostgresSaver(BasePostgresSaver):
def put_writes(
self,
config: RunnableConfig,
writes: List[tuple[str, Any]],
writes: Sequence[tuple[str, Any]],
task_id: str,
) -> None:
"""Store intermediate writes linked to a checkpoint.
@@ -1,6 +1,6 @@
import asyncio
from contextlib import asynccontextmanager
from typing import Any, AsyncIterator, Iterator, List, Optional, Union
from typing import Any, AsyncIterator, Iterator, Optional, Sequence, Union
from langchain_core.runnables import RunnableConfig
from psycopg import AsyncConnection, AsyncCursor, AsyncPipeline
@@ -291,7 +291,7 @@ class AsyncPostgresSaver(BasePostgresSaver):
async def aput_writes(
self,
config: RunnableConfig,
writes: list[tuple[str, Any]],
writes: Sequence[tuple[str, Any]],
task_id: str,
) -> None:
"""Store intermediate writes linked to a checkpoint asynchronously.
@@ -425,7 +425,7 @@ class AsyncPostgresSaver(BasePostgresSaver):
def put_writes(
self,
config: RunnableConfig,
writes: List[tuple[str, Any]],
writes: Sequence[tuple[str, Any]],
task_id: str,
) -> None:
"""Store intermediate writes linked to a checkpoint.
@@ -1,5 +1,5 @@
import random
from typing import Any, List, Optional, Tuple, cast
from typing import Any, List, Optional, Sequence, Tuple, cast
from langchain_core.runnables import RunnableConfig
from psycopg.types.json import Jsonb
@@ -209,7 +209,7 @@ class BasePostgresSaver(BaseCheckpointSaver[str]):
checkpoint_ns: str,
checkpoint_id: str,
task_id: str,
writes: list[tuple[str, Any]],
writes: Sequence[tuple[str, Any]],
) -> list[tuple[str, str, str, str, int, str, str, bytes]]:
return [
(