38
38
_Connection = typing .TypeVar ('_Connection' , bound = 'Connection' )
39
39
_Writer = typing .Callable [[bytes ],
40
40
typing .Coroutine [typing .Any , typing .Any , None ]]
41
+ _Record = typing .TypeVar ('_Record' , bound = '_cprotocol.Record' )
41
42
_RecordsType = typing .List ['_cprotocol.Record' ]
42
43
_RecordsExtraType = typing .Tuple [_RecordsType , bytes , bool ]
43
44
_AnyCallable = typing .Callable [..., typing .Any ]
@@ -478,7 +479,8 @@ async def _introspect_types(self, typeoids: typing.Set[int],
478
479
479
480
def cursor (self , query : str , * args : typing .Any ,
480
481
prefetch : typing .Optional [int ] = None ,
481
- timeout : typing .Optional [float ] = None ) -> cursor .CursorFactory :
482
+ timeout : typing .Optional [float ] = None ) \
483
+ -> 'cursor.CursorFactory[_cprotocol.Record]' :
482
484
"""Return a *cursor factory* for the specified query.
483
485
484
486
:param args: Query arguments.
@@ -494,7 +496,7 @@ def cursor(self, query: str, *args: typing.Any,
494
496
495
497
async def prepare (self , query : str , * ,
496
498
timeout : typing .Optional [float ] = None ) \
497
- -> prepared_stmt .PreparedStatement :
499
+ -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
498
500
"""Create a *prepared statement* for the specified query.
499
501
500
502
:param str query: Text of the query to create a prepared statement for.
@@ -507,7 +509,7 @@ async def prepare(self, query: str, *,
507
509
async def _prepare (self , query : str , * ,
508
510
timeout : typing .Optional [float ] = None ,
509
511
use_cache : bool = False ) \
510
- -> prepared_stmt .PreparedStatement :
512
+ -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
511
513
self ._check_open ()
512
514
stmt = await self ._get_statement (query , timeout , named = True ,
513
515
use_cache = use_cache )
@@ -917,7 +919,7 @@ async def _copy_out(self, copy_stmt: str,
917
919
output : OutputType [typing .AnyStr ],
918
920
timeout : typing .Optional [float ]) -> str :
919
921
try :
920
- path = compat .fspath (output ) # type: typing.Optional[typing.AnyStr] # type: ignore # noqa: E501
922
+ path = compat .fspath (output ) # type: typing.Optional[typing.AnyStr] # type: ignore[arg-type] # noqa: E501
921
923
except TypeError :
922
924
# output is not a path-like object
923
925
path = None
@@ -944,7 +946,7 @@ async def _copy_out(self, copy_stmt: str,
944
946
)
945
947
946
948
if writer is None :
947
- async def _writer (data : bytes ) -> None : # type: ignore
949
+ async def _writer (data : bytes ) -> None : # type: ignore[return]
948
950
await run_in_executor (None , f .write , data )
949
951
950
952
writer = _writer
@@ -959,7 +961,7 @@ async def _copy_in(self, copy_stmt: str,
959
961
source : SourceType [typing .AnyStr ],
960
962
timeout : typing .Optional [float ]) -> str :
961
963
try :
962
- path = compat .fspath (source ) # type: typing.Optional[typing.AnyStr] # type: ignore # noqa: E501
964
+ path = compat .fspath (source ) # type: typing.Optional[typing.AnyStr] # type: ignore[arg-type] # noqa: E501
963
965
except TypeError :
964
966
# source is not a path-like object
965
967
path = None
@@ -998,7 +1000,7 @@ async def __anext__(self) -> bytes:
998
1000
if len (data ) == 0 :
999
1001
raise StopAsyncIteration
1000
1002
else :
1001
- return data # type: ignore
1003
+ return data # type: ignore[return-value]
1002
1004
1003
1005
reader = _Reader ()
1004
1006
@@ -1290,7 +1292,7 @@ def _abort(self) -> None:
1290
1292
# Put the connection into the aborted state.
1291
1293
self ._aborted = True
1292
1294
self ._protocol .abort ()
1293
- self ._protocol = None # type: ignore
1295
+ self ._protocol = None # type: ignore[assignment]
1294
1296
1295
1297
def _cleanup (self ) -> None :
1296
1298
self ._call_termination_listeners ()
@@ -1384,7 +1386,7 @@ async def _cancel(self, waiter: 'asyncio.Future[None]') -> None:
1384
1386
waiter .set_exception (ex )
1385
1387
finally :
1386
1388
self ._cancellations .discard (
1387
- compat .current_asyncio_task (self ._loop ))
1389
+ compat .current_asyncio_task (self ._loop )) # type: ignore[arg-type] # noqa: E501
1388
1390
if not waiter .done ():
1389
1391
waiter .set_result (None )
1390
1392
@@ -1798,7 +1800,7 @@ async def connect(dsn: typing.Optional[str] = None, *,
1798
1800
max_cacheable_statement_size : int = 1024 * 15 ,
1799
1801
command_timeout : typing .Optional [float ] = None ,
1800
1802
ssl : typing .Optional [connect_utils .SSLType ] = None ,
1801
- connection_class : typing .Type [_Connection ] = Connection , # type: ignore # noqa: E501
1803
+ connection_class : typing .Type [_Connection ] = Connection , # type: ignore[assignment] # noqa: E501
1802
1804
server_settings : typing .Optional [
1803
1805
typing .Dict [str , str ]] = None ) -> _Connection :
1804
1806
r"""A coroutine to establish a connection to a PostgreSQL server.
@@ -2231,15 +2233,15 @@ def _extract_stack(limit: int = 10) -> str:
2231
2233
frame = sys ._getframe ().f_back
2232
2234
try :
2233
2235
stack = traceback .StackSummary .extract (
2234
- traceback .walk_stack (frame ), lookup_lines = False ) # type: typing.Union[traceback.StackSummary, typing.List[traceback.FrameSummary] ] # noqa: E501
2236
+ traceback .walk_stack (frame ), lookup_lines = False ) # type: ignore[arg-type ] # noqa: E501
2235
2237
finally :
2236
2238
del frame
2237
2239
2238
- apg_path = asyncpg .__path__ [0 ]
2240
+ apg_path = asyncpg .__path__ [0 ] # type: ignore[attr-defined]
2239
2241
i = 0
2240
2242
while i < len (stack ) and stack [i ][0 ].startswith (apg_path ):
2241
2243
i += 1
2242
- stack = stack [i :i + limit ]
2244
+ stack = stack [i :i + limit ] # type: ignore[assignment]
2243
2245
2244
2246
stack .reverse ()
2245
2247
return '' .join (traceback .format_list (stack ))
0 commit comments