3838_Connection = typing .TypeVar ('_Connection' , bound = 'Connection' )
3939_Writer = typing .Callable [[bytes ],
4040 typing .Coroutine [typing .Any , typing .Any , None ]]
41+ _Record = typing .TypeVar ('_Record' , bound = '_cprotocol.Record' )
4142_RecordsType = typing .List ['_cprotocol.Record' ]
4243_RecordsExtraType = typing .Tuple [_RecordsType , bytes , bool ]
4344_AnyCallable = typing .Callable [..., typing .Any ]
@@ -508,7 +509,7 @@ def cursor(
508509 prefetch : typing .Optional [int ] = None ,
509510 timeout : typing .Optional [float ] = None ,
510511 record_class : typing .Optional [typing .Any ] = None
511- ) -> cursor .CursorFactory :
512+ ) -> ' cursor.CursorFactory[_cprotocol.Record]' :
512513 """Return a *cursor factory* for the specified query.
513514
514515 :param args:
@@ -546,7 +547,7 @@ async def prepare(
546547 * ,
547548 timeout : typing .Optional [float ] = None ,
548549 record_class : typing .Optional [typing .Any ] = None
549- ) -> prepared_stmt .PreparedStatement :
550+ ) -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
550551 """Create a *prepared statement* for the specified query.
551552
552553 :param str query:
@@ -579,7 +580,7 @@ async def _prepare(
579580 timeout : typing .Optional [float ] = None ,
580581 use_cache : bool = False ,
581582 record_class : typing .Optional [typing .Any ] = None
582- ) -> prepared_stmt .PreparedStatement :
583+ ) -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
583584 self ._check_open ()
584585 stmt = await self ._get_statement (
585586 query ,
@@ -1038,7 +1039,7 @@ async def _copy_out(self, copy_stmt: str,
10381039 output : OutputType [typing .AnyStr ],
10391040 timeout : typing .Optional [float ]) -> str :
10401041 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
10421043 except TypeError :
10431044 # output is not a path-like object
10441045 path = None
@@ -1065,7 +1066,7 @@ async def _copy_out(self, copy_stmt: str,
10651066 )
10661067
10671068 if writer is None :
1068- async def _writer (data : bytes ) -> None : # type: ignore
1069+ async def _writer (data : bytes ) -> None : # type: ignore[return]
10691070 await run_in_executor (None , f .write , data )
10701071
10711072 writer = _writer
@@ -1080,7 +1081,7 @@ async def _copy_in(self, copy_stmt: str,
10801081 source : SourceType [typing .AnyStr ],
10811082 timeout : typing .Optional [float ]) -> str :
10821083 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
10841085 except TypeError :
10851086 # source is not a path-like object
10861087 path = None
@@ -1119,7 +1120,7 @@ async def __anext__(self) -> bytes:
11191120 if len (data ) == 0 :
11201121 raise StopAsyncIteration
11211122 else :
1122- return data # type: ignore
1123+ return data # type: ignore[return-value]
11231124
11241125 reader = _Reader ()
11251126
@@ -1411,7 +1412,7 @@ def _abort(self) -> None:
14111412 # Put the connection into the aborted state.
14121413 self ._aborted = True
14131414 self ._protocol .abort ()
1414- self ._protocol = None # type: ignore
1415+ self ._protocol = None # type: ignore[assignment]
14151416
14161417 def _cleanup (self ) -> None :
14171418 self ._call_termination_listeners ()
@@ -1508,7 +1509,7 @@ async def _cancel(self, waiter: 'asyncio.Future[None]') -> None:
15081509 waiter .set_exception (ex )
15091510 finally :
15101511 self ._cancellations .discard (
1511- compat .current_asyncio_task (self ._loop ))
1512+ compat .current_asyncio_task (self ._loop )) # type: ignore[arg-type] # noqa: E501
15121513 if not waiter .done ():
15131514 waiter .set_result (None )
15141515
@@ -1994,7 +1995,7 @@ async def connect(dsn: typing.Optional[str] = None, *,
19941995 max_cacheable_statement_size : int = 1024 * 15 ,
19951996 command_timeout : typing .Optional [float ] = None ,
19961997 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
19981999 record_class : typing .Optional [typing .Any ] = protocol .Record ,
19992000 server_settings : typing .Optional [
20002001 typing .Dict [str , str ]] = None ) -> _Connection :
@@ -2450,15 +2451,15 @@ def _extract_stack(limit: int = 10) -> str:
24502451 frame = sys ._getframe ().f_back
24512452 try :
24522453 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
24542455 finally :
24552456 del frame
24562457
2457- apg_path = asyncpg .__path__ [0 ]
2458+ apg_path = asyncpg .__path__ [0 ] # type: ignore[attr-defined]
24582459 i = 0
24592460 while i < len (stack ) and stack [i ][0 ].startswith (apg_path ):
24602461 i += 1
2461- stack = stack [i :i + limit ]
2462+ stack = stack [i :i + limit ] # type: ignore[assignment]
24622463
24632464 stack .reverse ()
24642465 return '' .join (traceback .format_list (stack ))
0 commit comments