3434 Tuple ,
3535 Type ,
3636 TypeVar ,
37+ Union ,
3738 cast ,
3839 overload ,
3940)
100101}
101102
102103
104+ class _PoolConnection (Connection ):
105+ """
106+ A Connection from twisted.enterprise.adbapi.Connection.
107+ """
108+
109+ def reconnect (self ) -> None :
110+ ...
111+
112+
103113def make_pool (
104114 reactor : IReactorCore ,
105115 db_config : DatabaseConnectionConfig ,
@@ -856,7 +866,8 @@ async def _runInteraction() -> R:
856866 try :
857867 with opentracing .start_active_span (f"db.{ desc } " ):
858868 result = await self .runWithConnection (
859- self .new_transaction ,
869+ # mypy seems to have an issue with this, maybe a bug?
870+ self .new_transaction , # type: ignore[arg-type]
860871 desc ,
861872 after_callbacks ,
862873 async_after_callbacks ,
@@ -892,7 +903,7 @@ async def _runInteraction() -> R:
892903
893904 async def runWithConnection (
894905 self ,
895- func : Callable [... , R ],
906+ func : Callable [Concatenate [ LoggingDatabaseConnection , P ] , R ],
896907 * args : Any ,
897908 db_autocommit : bool = False ,
898909 isolation_level : Optional [int ] = None ,
@@ -926,7 +937,7 @@ async def runWithConnection(
926937
927938 start_time = monotonic_time ()
928939
929- def inner_func (conn , * args , ** kwargs ) :
940+ def inner_func (conn : _PoolConnection , * args : P . args , ** kwargs : P . kwargs ) -> R :
930941 # We shouldn't be in a transaction. If we are then something
931942 # somewhere hasn't committed after doing work. (This is likely only
932943 # possible during startup, as `run*` will ensure changes are
@@ -1019,7 +1030,7 @@ async def execute(
10191030 decoder : Optional [Callable [[Cursor ], R ]],
10201031 query : str ,
10211032 * args : Any ,
1022- ) -> R :
1033+ ) -> Union [ List [ Tuple [ Any , ...]], R ] :
10231034 """Runs a single query for a result set.
10241035
10251036 Args:
@@ -1032,7 +1043,7 @@ async def execute(
10321043 The result of decoder(results)
10331044 """
10341045
1035- def interaction (txn ) :
1046+ def interaction (txn : LoggingTransaction ) -> Union [ List [ Tuple [ Any , ...]], R ] :
10361047 txn .execute (query , args )
10371048 if decoder :
10381049 return decoder (txn )
0 commit comments