34
34
Tuple ,
35
35
Type ,
36
36
TypeVar ,
37
+ Union ,
37
38
cast ,
38
39
overload ,
39
40
)
100
101
}
101
102
102
103
104
+ class _PoolConnection (Connection ):
105
+ """
106
+ A Connection from twisted.enterprise.adbapi.Connection.
107
+ """
108
+
109
+ def reconnect (self ) -> None :
110
+ ...
111
+
112
+
103
113
def make_pool (
104
114
reactor : IReactorCore ,
105
115
db_config : DatabaseConnectionConfig ,
@@ -856,7 +866,8 @@ async def _runInteraction() -> R:
856
866
try :
857
867
with opentracing .start_active_span (f"db.{ desc } " ):
858
868
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]
860
871
desc ,
861
872
after_callbacks ,
862
873
async_after_callbacks ,
@@ -892,7 +903,7 @@ async def _runInteraction() -> R:
892
903
893
904
async def runWithConnection (
894
905
self ,
895
- func : Callable [... , R ],
906
+ func : Callable [Concatenate [ LoggingDatabaseConnection , P ] , R ],
896
907
* args : Any ,
897
908
db_autocommit : bool = False ,
898
909
isolation_level : Optional [int ] = None ,
@@ -926,7 +937,7 @@ async def runWithConnection(
926
937
927
938
start_time = monotonic_time ()
928
939
929
- def inner_func (conn , * args , ** kwargs ) :
940
+ def inner_func (conn : _PoolConnection , * args : P . args , ** kwargs : P . kwargs ) -> R :
930
941
# We shouldn't be in a transaction. If we are then something
931
942
# somewhere hasn't committed after doing work. (This is likely only
932
943
# possible during startup, as `run*` will ensure changes are
@@ -1019,7 +1030,7 @@ async def execute(
1019
1030
decoder : Optional [Callable [[Cursor ], R ]],
1020
1031
query : str ,
1021
1032
* args : Any ,
1022
- ) -> R :
1033
+ ) -> Union [ List [ Tuple [ Any , ...]], R ] :
1023
1034
"""Runs a single query for a result set.
1024
1035
1025
1036
Args:
@@ -1032,7 +1043,7 @@ async def execute(
1032
1043
The result of decoder(results)
1033
1044
"""
1034
1045
1035
- def interaction (txn ) :
1046
+ def interaction (txn : LoggingTransaction ) -> Union [ List [ Tuple [ Any , ...]], R ] :
1036
1047
txn .execute (query , args )
1037
1048
if decoder :
1038
1049
return decoder (txn )
0 commit comments