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 ]
@@ -447,7 +448,8 @@ async def _introspect_types(self, typeoids: typing.Set[int],
447448
448449 def cursor (self , query : str , * args : typing .Any ,
449450 prefetch : typing .Optional [int ] = None ,
450- timeout : typing .Optional [float ] = None ) -> cursor .CursorFactory :
451+ timeout : typing .Optional [float ] = None ) \
452+ -> 'cursor.CursorFactory[_cprotocol.Record]' :
451453 """Return a *cursor factory* for the specified query.
452454
453455 :param args: Query arguments.
@@ -463,7 +465,7 @@ def cursor(self, query: str, *args: typing.Any,
463465
464466 async def prepare (self , query : str , * ,
465467 timeout : typing .Optional [float ] = None ) \
466- -> prepared_stmt .PreparedStatement :
468+ -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
467469 """Create a *prepared statement* for the specified query.
468470
469471 :param str query: Text of the query to create a prepared statement for.
@@ -476,7 +478,7 @@ async def prepare(self, query: str, *,
476478 async def _prepare (self , query : str , * ,
477479 timeout : typing .Optional [float ] = None ,
478480 use_cache : bool = False ) \
479- -> prepared_stmt .PreparedStatement :
481+ -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
480482 self ._check_open ()
481483 stmt = await self ._get_statement (query , timeout , named = True ,
482484 use_cache = use_cache )
@@ -886,7 +888,7 @@ async def _copy_out(self, copy_stmt: str,
886888 output : OutputType [typing .AnyStr ],
887889 timeout : typing .Optional [float ]) -> str :
888890 try :
889- path = compat .fspath (output ) # type: typing.Optional[typing.AnyStr] # type: ignore # noqa: E501
891+ path = compat .fspath (output ) # type: typing.Optional[typing.AnyStr] # type: ignore[arg-type] # noqa: E501
890892 except TypeError :
891893 # output is not a path-like object
892894 path = None
@@ -913,7 +915,7 @@ async def _copy_out(self, copy_stmt: str,
913915 )
914916
915917 if writer is None :
916- async def _writer (data : bytes ) -> None : # type: ignore
918+ async def _writer (data : bytes ) -> None : # type: ignore[return]
917919 await run_in_executor (None , f .write , data )
918920
919921 writer = _writer
@@ -928,7 +930,7 @@ async def _copy_in(self, copy_stmt: str,
928930 source : SourceType [typing .AnyStr ],
929931 timeout : typing .Optional [float ]) -> str :
930932 try :
931- path = compat .fspath (source ) # type: typing.Optional[typing.AnyStr] # type: ignore # noqa: E501
933+ path = compat .fspath (source ) # type: typing.Optional[typing.AnyStr] # type: ignore[arg-type] # noqa: E501
932934 except TypeError :
933935 # source is not a path-like object
934936 path = None
@@ -967,7 +969,7 @@ async def __anext__(self) -> bytes:
967969 if len (data ) == 0 :
968970 raise StopAsyncIteration
969971 else :
970- return data # type: ignore
972+ return data # type: ignore[return-value]
971973
972974 reader = _Reader ()
973975
@@ -1259,7 +1261,7 @@ def _abort(self) -> None:
12591261 # Put the connection into the aborted state.
12601262 self ._aborted = True
12611263 self ._protocol .abort ()
1262- self ._protocol = None # type: ignore
1264+ self ._protocol = None # type: ignore[assignment]
12631265
12641266 def _cleanup (self ) -> None :
12651267 # Free the resources associated with this connection.
@@ -1352,7 +1354,7 @@ async def _cancel(self, waiter: 'asyncio.Future[None]') -> None:
13521354 waiter .set_exception (ex )
13531355 finally :
13541356 self ._cancellations .discard (
1355- compat .current_asyncio_task (self ._loop ))
1357+ compat .current_asyncio_task (self ._loop )) # type: ignore[arg-type] # noqa: E501
13561358 if not waiter .done ():
13571359 waiter .set_result (None )
13581360
@@ -1747,7 +1749,7 @@ async def connect(dsn: typing.Optional[str] = None, *,
17471749 max_cacheable_statement_size : int = 1024 * 15 ,
17481750 command_timeout : typing .Optional [float ] = None ,
17491751 ssl : typing .Optional [connect_utils .SSLType ] = None ,
1750- connection_class : typing .Type [_Connection ] = Connection , # type: ignore # noqa: E501
1752+ connection_class : typing .Type [_Connection ] = Connection , # type: ignore[assignment] # noqa: E501
17511753 server_settings : typing .Optional [
17521754 typing .Dict [str , str ]] = None ) -> _Connection :
17531755 r"""A coroutine to establish a connection to a PostgreSQL server.
@@ -2180,15 +2182,15 @@ def _extract_stack(limit: int = 10) -> str:
21802182 frame = sys ._getframe ().f_back
21812183 try :
21822184 stack = traceback .StackSummary .extract (
2183- traceback .walk_stack (frame ), lookup_lines = False ) # type: typing.Union[traceback.StackSummary, typing.List[traceback.FrameSummary] ] # noqa: E501
2185+ traceback .walk_stack (frame ), lookup_lines = False ) # type: ignore[arg-type ] # noqa: E501
21842186 finally :
21852187 del frame
21862188
2187- apg_path = asyncpg .__path__ [0 ]
2189+ apg_path = asyncpg .__path__ [0 ] # type: ignore[attr-defined]
21882190 i = 0
21892191 while i < len (stack ) and stack [i ][0 ].startswith (apg_path ):
21902192 i += 1
2191- stack = stack [i :i + limit ]
2193+ stack = stack [i :i + limit ] # type: ignore[assignment]
21922194
21932195 stack .reverse ()
21942196 return '' .join (traceback .format_list (stack ))
0 commit comments