1
1
"""Follows https://langchain-ai.github.io/langgraph/how-tos/human_in_the_loop/time-travel"""
2
2
3
3
import os
4
- from typing import TypedDict
4
+ from typing import Generator , TypedDict
5
5
6
6
import pytest
7
7
10
10
from langgraph .checkpoint .mongodb import MongoDBSaver
11
11
from langgraph .graph import END , StateGraph
12
12
from langgraph .graph .graph import CompiledGraph
13
+ from langchain_core .runnables import RunnableConfig
13
14
14
15
# --- Configuration ---
15
16
MONGODB_URI = os .environ .get ("MONGODB_URI" , "mongodb://localhost:27017" )
19
20
20
21
21
22
@pytest .fixture (scope = "function" )
22
- def checkpointer_memory ():
23
+ def checkpointer_memory () -> Generator [ InMemorySaver , None , None ] :
23
24
yield InMemorySaver ()
24
25
25
26
26
27
@pytest .fixture (scope = "function" )
27
- def checkpointer_mongodb ():
28
+ def checkpointer_mongodb () -> Generator [ MongoDBSaver , None , None ] :
28
29
with MongoDBSaver .from_conn_string (
29
30
MONGODB_URI ,
30
31
db_name = DB_NAME ,
@@ -45,7 +46,7 @@ def checkpointer_mongodb():
45
46
46
47
47
48
@pytest .mark .parametrize ("checkpointer_name" , ALL_CHECKPOINTERS_SYNC )
48
- def test (request : pytest .FixtureRequest , checkpointer_name : str ):
49
+ def test (request : pytest .FixtureRequest , checkpointer_name : str ) -> None :
49
50
checkpointer : BaseCheckpointSaver = request .getfixturevalue (checkpointer_name )
50
51
assert isinstance (checkpointer , BaseCheckpointSaver )
51
52
@@ -80,7 +81,7 @@ def node_double(state: State) -> State:
80
81
)
81
82
82
83
# --- Configure ---
83
- config = {"configurable" : {"thread_id" : "thread_#1" }}
84
+ config : RunnableConfig = {"configurable" : {"thread_id" : "thread_#1" }}
84
85
initial_input = {"value" : 10 , "step" : 0 }
85
86
86
87
# --- 1st invoke, with Interruption
0 commit comments