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 ]
@@ -478,7 +479,8 @@ async def _introspect_types(self, typeoids: typing.Set[int],
478479
479480 def cursor (self , query : str , * args : typing .Any ,
480481 prefetch : typing .Optional [int ] = None ,
481- timeout : typing .Optional [float ] = None ) -> cursor .CursorFactory :
482+ timeout : typing .Optional [float ] = None ) \
483+ -> 'cursor.CursorFactory[_cprotocol.Record]' :
482484 """Return a *cursor factory* for the specified query.
483485
484486 :param args: Query arguments.
@@ -494,7 +496,7 @@ def cursor(self, query: str, *args: typing.Any,
494496
495497 async def prepare (self , query : str , * ,
496498 timeout : typing .Optional [float ] = None ) \
497- -> prepared_stmt .PreparedStatement :
499+ -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
498500 """Create a *prepared statement* for the specified query.
499501
500502 :param str query: Text of the query to create a prepared statement for.
@@ -507,7 +509,7 @@ async def prepare(self, query: str, *,
507509 async def _prepare (self , query : str , * ,
508510 timeout : typing .Optional [float ] = None ,
509511 use_cache : bool = False ) \
510- -> prepared_stmt .PreparedStatement :
512+ -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
511513 self ._check_open ()
512514 stmt = await self ._get_statement (query , timeout , named = True ,
513515 use_cache = use_cache )
@@ -917,7 +919,7 @@ async def _copy_out(self, copy_stmt: str,
917919 output : OutputType [typing .AnyStr ],
918920 timeout : typing .Optional [float ]) -> str :
919921 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
921923 except TypeError :
922924 # output is not a path-like object
923925 path = None
@@ -944,7 +946,7 @@ async def _copy_out(self, copy_stmt: str,
944946 )
945947
946948 if writer is None :
947- async def _writer (data : bytes ) -> None : # type: ignore
949+ async def _writer (data : bytes ) -> None : # type: ignore[return]
948950 await run_in_executor (None , f .write , data )
949951
950952 writer = _writer
@@ -959,7 +961,7 @@ async def _copy_in(self, copy_stmt: str,
959961 source : SourceType [typing .AnyStr ],
960962 timeout : typing .Optional [float ]) -> str :
961963 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
963965 except TypeError :
964966 # source is not a path-like object
965967 path = None
@@ -998,7 +1000,7 @@ async def __anext__(self) -> bytes:
9981000 if len (data ) == 0 :
9991001 raise StopAsyncIteration
10001002 else :
1001- return data # type: ignore
1003+ return data # type: ignore[return-value]
10021004
10031005 reader = _Reader ()
10041006
@@ -1290,7 +1292,7 @@ def _abort(self) -> None:
12901292 # Put the connection into the aborted state.
12911293 self ._aborted = True
12921294 self ._protocol .abort ()
1293- self ._protocol = None # type: ignore
1295+ self ._protocol = None # type: ignore[assignment]
12941296
12951297 def _cleanup (self ) -> None :
12961298 self ._call_termination_listeners ()
@@ -1384,7 +1386,7 @@ async def _cancel(self, waiter: 'asyncio.Future[None]') -> None:
13841386 waiter .set_exception (ex )
13851387 finally :
13861388 self ._cancellations .discard (
1387- compat .current_asyncio_task (self ._loop ))
1389+ compat .current_asyncio_task (self ._loop )) # type: ignore[arg-type] # noqa: E501
13881390 if not waiter .done ():
13891391 waiter .set_result (None )
13901392
@@ -1798,7 +1800,7 @@ async def connect(dsn: typing.Optional[str] = None, *,
17981800 max_cacheable_statement_size : int = 1024 * 15 ,
17991801 command_timeout : typing .Optional [float ] = None ,
18001802 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
18021804 server_settings : typing .Optional [
18031805 typing .Dict [str , str ]] = None ) -> _Connection :
18041806 r"""A coroutine to establish a connection to a PostgreSQL server.
@@ -2231,15 +2233,15 @@ def _extract_stack(limit: int = 10) -> str:
22312233 frame = sys ._getframe ().f_back
22322234 try :
22332235 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
22352237 finally :
22362238 del frame
22372239
2238- apg_path = asyncpg .__path__ [0 ]
2240+ apg_path = asyncpg .__path__ [0 ] # type: ignore[attr-defined]
22392241 i = 0
22402242 while i < len (stack ) and stack [i ][0 ].startswith (apg_path ):
22412243 i += 1
2242- stack = stack [i :i + limit ]
2244+ stack = stack [i :i + limit ] # type: ignore[assignment]
22432245
22442246 stack .reverse ()
22452247 return '' .join (traceback .format_list (stack ))
0 commit comments