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 ]
@@ -508,7 +509,7 @@ def cursor(
508
509
prefetch : typing .Optional [int ] = None ,
509
510
timeout : typing .Optional [float ] = None ,
510
511
record_class : typing .Optional [typing .Any ] = None
511
- ) -> cursor .CursorFactory :
512
+ ) -> ' cursor.CursorFactory[_cprotocol.Record]' :
512
513
"""Return a *cursor factory* for the specified query.
513
514
514
515
:param args:
@@ -546,7 +547,7 @@ async def prepare(
546
547
* ,
547
548
timeout : typing .Optional [float ] = None ,
548
549
record_class : typing .Optional [typing .Any ] = None
549
- ) -> prepared_stmt .PreparedStatement :
550
+ ) -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
550
551
"""Create a *prepared statement* for the specified query.
551
552
552
553
:param str query:
@@ -579,7 +580,7 @@ async def _prepare(
579
580
timeout : typing .Optional [float ] = None ,
580
581
use_cache : bool = False ,
581
582
record_class : typing .Optional [typing .Any ] = None
582
- ) -> prepared_stmt .PreparedStatement :
583
+ ) -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
583
584
self ._check_open ()
584
585
stmt = await self ._get_statement (
585
586
query ,
@@ -1038,7 +1039,7 @@ async def _copy_out(self, copy_stmt: str,
1038
1039
output : OutputType [typing .AnyStr ],
1039
1040
timeout : typing .Optional [float ]) -> str :
1040
1041
try :
1041
- path = compat .fspath (output ) # type: typing.Optional[typing.AnyStr] # type: ignore # noqa: E501
1042
+ path = compat .fspath (output ) # type: typing.Optional[typing.AnyStr] # type: ignore[arg-type] # noqa: E501
1042
1043
except TypeError :
1043
1044
# output is not a path-like object
1044
1045
path = None
@@ -1065,7 +1066,7 @@ async def _copy_out(self, copy_stmt: str,
1065
1066
)
1066
1067
1067
1068
if writer is None :
1068
- async def _writer (data : bytes ) -> None : # type: ignore
1069
+ async def _writer (data : bytes ) -> None : # type: ignore[return]
1069
1070
await run_in_executor (None , f .write , data )
1070
1071
1071
1072
writer = _writer
@@ -1080,7 +1081,7 @@ async def _copy_in(self, copy_stmt: str,
1080
1081
source : SourceType [typing .AnyStr ],
1081
1082
timeout : typing .Optional [float ]) -> str :
1082
1083
try :
1083
- path = compat .fspath (source ) # type: typing.Optional[typing.AnyStr] # type: ignore # noqa: E501
1084
+ path = compat .fspath (source ) # type: typing.Optional[typing.AnyStr] # type: ignore[arg-type] # noqa: E501
1084
1085
except TypeError :
1085
1086
# source is not a path-like object
1086
1087
path = None
@@ -1119,7 +1120,7 @@ async def __anext__(self) -> bytes:
1119
1120
if len (data ) == 0 :
1120
1121
raise StopAsyncIteration
1121
1122
else :
1122
- return data # type: ignore
1123
+ return data # type: ignore[return-value]
1123
1124
1124
1125
reader = _Reader ()
1125
1126
@@ -1411,7 +1412,7 @@ def _abort(self) -> None:
1411
1412
# Put the connection into the aborted state.
1412
1413
self ._aborted = True
1413
1414
self ._protocol .abort ()
1414
- self ._protocol = None # type: ignore
1415
+ self ._protocol = None # type: ignore[assignment]
1415
1416
1416
1417
def _cleanup (self ) -> None :
1417
1418
self ._call_termination_listeners ()
@@ -1508,7 +1509,7 @@ async def _cancel(self, waiter: 'asyncio.Future[None]') -> None:
1508
1509
waiter .set_exception (ex )
1509
1510
finally :
1510
1511
self ._cancellations .discard (
1511
- compat .current_asyncio_task (self ._loop ))
1512
+ compat .current_asyncio_task (self ._loop )) # type: ignore[arg-type] # noqa: E501
1512
1513
if not waiter .done ():
1513
1514
waiter .set_result (None )
1514
1515
@@ -1994,7 +1995,7 @@ async def connect(dsn: typing.Optional[str] = None, *,
1994
1995
max_cacheable_statement_size : int = 1024 * 15 ,
1995
1996
command_timeout : typing .Optional [float ] = None ,
1996
1997
ssl : typing .Optional [connect_utils .SSLType ] = None ,
1997
- connection_class : typing .Type [_Connection ] = Connection , # type: ignore # noqa: E501
1998
+ connection_class : typing .Type [_Connection ] = Connection , # type: ignore[assignment] # noqa: E501
1998
1999
record_class : typing .Optional [typing .Any ] = protocol .Record ,
1999
2000
server_settings : typing .Optional [
2000
2001
typing .Dict [str , str ]] = None ) -> _Connection :
@@ -2450,15 +2451,15 @@ def _extract_stack(limit: int = 10) -> str:
2450
2451
frame = sys ._getframe ().f_back
2451
2452
try :
2452
2453
stack = traceback .StackSummary .extract (
2453
- traceback .walk_stack (frame ), lookup_lines = False ) # type: typing.Union[traceback.StackSummary, typing.List[traceback.FrameSummary] ] # noqa: E501
2454
+ traceback .walk_stack (frame ), lookup_lines = False ) # type: ignore[arg-type ] # noqa: E501
2454
2455
finally :
2455
2456
del frame
2456
2457
2457
- apg_path = asyncpg .__path__ [0 ]
2458
+ apg_path = asyncpg .__path__ [0 ] # type: ignore[attr-defined]
2458
2459
i = 0
2459
2460
while i < len (stack ) and stack [i ][0 ].startswith (apg_path ):
2460
2461
i += 1
2461
- stack = stack [i :i + limit ]
2462
+ stack = stack [i :i + limit ] # type: ignore[assignment]
2462
2463
2463
2464
stack .reverse ()
2464
2465
return '' .join (traceback .format_list (stack ))
0 commit comments