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 ]
@@ -548,7 +549,7 @@ def cursor(
548
549
prefetch : typing .Optional [int ] = None ,
549
550
timeout : typing .Optional [float ] = None ,
550
551
record_class : typing .Optional [typing .Any ] = None
551
- ) -> cursor .CursorFactory :
552
+ ) -> ' cursor.CursorFactory[_cprotocol.Record]' :
552
553
"""Return a *cursor factory* for the specified query.
553
554
554
555
:param args:
@@ -586,7 +587,7 @@ async def prepare(
586
587
* ,
587
588
timeout : typing .Optional [float ] = None ,
588
589
record_class : typing .Optional [typing .Any ] = None
589
- ) -> prepared_stmt .PreparedStatement :
590
+ ) -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
590
591
"""Create a *prepared statement* for the specified query.
591
592
592
593
:param str query:
@@ -619,7 +620,7 @@ async def _prepare(
619
620
timeout : typing .Optional [float ] = None ,
620
621
use_cache : bool = False ,
621
622
record_class : typing .Optional [typing .Any ] = None
622
- ) -> prepared_stmt .PreparedStatement :
623
+ ) -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
623
624
self ._check_open ()
624
625
stmt = await self ._get_statement (
625
626
query ,
@@ -1078,7 +1079,7 @@ async def _copy_out(self, copy_stmt: str,
1078
1079
output : OutputType [typing .AnyStr ],
1079
1080
timeout : typing .Optional [float ]) -> str :
1080
1081
try :
1081
- path = compat .fspath (output ) # type: typing.Optional[typing.AnyStr] # type: ignore # noqa: E501
1082
+ path = compat .fspath (output ) # type: typing.Optional[typing.AnyStr] # type: ignore[arg-type] # noqa: E501
1082
1083
except TypeError :
1083
1084
# output is not a path-like object
1084
1085
path = None
@@ -1105,7 +1106,7 @@ async def _copy_out(self, copy_stmt: str,
1105
1106
)
1106
1107
1107
1108
if writer is None :
1108
- async def _writer (data : bytes ) -> None : # type: ignore
1109
+ async def _writer (data : bytes ) -> None : # type: ignore[return]
1109
1110
await run_in_executor (None , f .write , data )
1110
1111
1111
1112
writer = _writer
@@ -1120,7 +1121,7 @@ async def _copy_in(self, copy_stmt: str,
1120
1121
source : SourceType [typing .AnyStr ],
1121
1122
timeout : typing .Optional [float ]) -> str :
1122
1123
try :
1123
- path = compat .fspath (source ) # type: typing.Optional[typing.AnyStr] # type: ignore # noqa: E501
1124
+ path = compat .fspath (source ) # type: typing.Optional[typing.AnyStr] # type: ignore[arg-type] # noqa: E501
1124
1125
except TypeError :
1125
1126
# source is not a path-like object
1126
1127
path = None
@@ -1159,7 +1160,7 @@ async def __anext__(self) -> bytes:
1159
1160
if len (data ) == 0 :
1160
1161
raise StopAsyncIteration
1161
1162
else :
1162
- return data # type: ignore
1163
+ return data # type: ignore[return-value]
1163
1164
1164
1165
reader = _Reader ()
1165
1166
@@ -1434,7 +1435,7 @@ def _abort(self) -> None:
1434
1435
# Put the connection into the aborted state.
1435
1436
self ._aborted = True
1436
1437
self ._protocol .abort ()
1437
- self ._protocol = None # type: ignore
1438
+ self ._protocol = None # type: ignore[assignment]
1438
1439
1439
1440
def _cleanup (self ) -> None :
1440
1441
self ._call_termination_listeners ()
@@ -1533,7 +1534,7 @@ async def _cancel(self, waiter: 'asyncio.Future[None]') -> None:
1533
1534
waiter .set_exception (ex )
1534
1535
finally :
1535
1536
self ._cancellations .discard (
1536
- compat .current_asyncio_task (self ._loop ))
1537
+ compat .current_asyncio_task (self ._loop )) # type: ignore[arg-type] # noqa: E501
1537
1538
if not waiter .done ():
1538
1539
waiter .set_result (None )
1539
1540
@@ -2032,7 +2033,7 @@ async def connect(dsn: typing.Optional[str] = None, *,
2032
2033
max_cacheable_statement_size : int = 1024 * 15 ,
2033
2034
command_timeout : typing .Optional [float ] = None ,
2034
2035
ssl : typing .Optional [connect_utils .SSLType ] = None ,
2035
- connection_class : typing .Type [_Connection ] = Connection , # type: ignore # noqa: E501
2036
+ connection_class : typing .Type [_Connection ] = Connection , # type: ignore[assignment] # noqa: E501
2036
2037
record_class : typing .Optional [typing .Any ] = protocol .Record ,
2037
2038
server_settings : typing .Optional [
2038
2039
typing .Dict [str , str ]] = None ) -> _Connection :
@@ -2488,15 +2489,15 @@ def _extract_stack(limit: int = 10) -> str:
2488
2489
frame = sys ._getframe ().f_back
2489
2490
try :
2490
2491
stack = traceback .StackSummary .extract (
2491
- traceback .walk_stack (frame ), lookup_lines = False ) # type: typing.Union[traceback.StackSummary, typing.List[traceback.FrameSummary] ] # noqa: E501
2492
+ traceback .walk_stack (frame ), lookup_lines = False ) # type: ignore[arg-type ] # noqa: E501
2492
2493
finally :
2493
2494
del frame
2494
2495
2495
- apg_path = asyncpg .__path__ [0 ]
2496
+ apg_path = asyncpg .__path__ [0 ] # type: ignore[attr-defined]
2496
2497
i = 0
2497
2498
while i < len (stack ) and stack [i ][0 ].startswith (apg_path ):
2498
2499
i += 1
2499
- stack = stack [i :i + limit ]
2500
+ stack = stack [i :i + limit ] # type: ignore[assignment]
2500
2501
2501
2502
stack .reverse ()
2502
2503
return '' .join (traceback .format_list (stack ))
0 commit comments