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 ]
@@ -548,7 +549,7 @@ def cursor(
548549 prefetch : typing .Optional [int ] = None ,
549550 timeout : typing .Optional [float ] = None ,
550551 record_class : typing .Optional [typing .Any ] = None
551- ) -> cursor .CursorFactory :
552+ ) -> ' cursor.CursorFactory[_cprotocol.Record]' :
552553 """Return a *cursor factory* for the specified query.
553554
554555 :param args:
@@ -586,7 +587,7 @@ async def prepare(
586587 * ,
587588 timeout : typing .Optional [float ] = None ,
588589 record_class : typing .Optional [typing .Any ] = None
589- ) -> prepared_stmt .PreparedStatement :
590+ ) -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
590591 """Create a *prepared statement* for the specified query.
591592
592593 :param str query:
@@ -619,7 +620,7 @@ async def _prepare(
619620 timeout : typing .Optional [float ] = None ,
620621 use_cache : bool = False ,
621622 record_class : typing .Optional [typing .Any ] = None
622- ) -> prepared_stmt .PreparedStatement :
623+ ) -> prepared_stmt .PreparedStatement [ '_cprotocol.Record' ] :
623624 self ._check_open ()
624625 stmt = await self ._get_statement (
625626 query ,
@@ -1078,7 +1079,7 @@ async def _copy_out(self, copy_stmt: str,
10781079 output : OutputType [typing .AnyStr ],
10791080 timeout : typing .Optional [float ]) -> str :
10801081 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
10821083 except TypeError :
10831084 # output is not a path-like object
10841085 path = None
@@ -1105,7 +1106,7 @@ async def _copy_out(self, copy_stmt: str,
11051106 )
11061107
11071108 if writer is None :
1108- async def _writer (data : bytes ) -> None : # type: ignore
1109+ async def _writer (data : bytes ) -> None : # type: ignore[return]
11091110 await run_in_executor (None , f .write , data )
11101111
11111112 writer = _writer
@@ -1120,7 +1121,7 @@ async def _copy_in(self, copy_stmt: str,
11201121 source : SourceType [typing .AnyStr ],
11211122 timeout : typing .Optional [float ]) -> str :
11221123 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
11241125 except TypeError :
11251126 # source is not a path-like object
11261127 path = None
@@ -1159,7 +1160,7 @@ async def __anext__(self) -> bytes:
11591160 if len (data ) == 0 :
11601161 raise StopAsyncIteration
11611162 else :
1162- return data # type: ignore
1163+ return data # type: ignore[return-value]
11631164
11641165 reader = _Reader ()
11651166
@@ -1434,7 +1435,7 @@ def _abort(self) -> None:
14341435 # Put the connection into the aborted state.
14351436 self ._aborted = True
14361437 self ._protocol .abort ()
1437- self ._protocol = None # type: ignore
1438+ self ._protocol = None # type: ignore[assignment]
14381439
14391440 def _cleanup (self ) -> None :
14401441 self ._call_termination_listeners ()
@@ -1533,7 +1534,7 @@ async def _cancel(self, waiter: 'asyncio.Future[None]') -> None:
15331534 waiter .set_exception (ex )
15341535 finally :
15351536 self ._cancellations .discard (
1536- compat .current_asyncio_task (self ._loop ))
1537+ compat .current_asyncio_task (self ._loop )) # type: ignore[arg-type] # noqa: E501
15371538 if not waiter .done ():
15381539 waiter .set_result (None )
15391540
@@ -2032,7 +2033,7 @@ async def connect(dsn: typing.Optional[str] = None, *,
20322033 max_cacheable_statement_size : int = 1024 * 15 ,
20332034 command_timeout : typing .Optional [float ] = None ,
20342035 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
20362037 record_class : typing .Optional [typing .Any ] = protocol .Record ,
20372038 server_settings : typing .Optional [
20382039 typing .Dict [str , str ]] = None ) -> _Connection :
@@ -2488,15 +2489,15 @@ def _extract_stack(limit: int = 10) -> str:
24882489 frame = sys ._getframe ().f_back
24892490 try :
24902491 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
24922493 finally :
24932494 del frame
24942495
2495- apg_path = asyncpg .__path__ [0 ]
2496+ apg_path = asyncpg .__path__ [0 ] # type: ignore[attr-defined]
24962497 i = 0
24972498 while i < len (stack ) and stack [i ][0 ].startswith (apg_path ):
24982499 i += 1
2499- stack = stack [i :i + limit ]
2500+ stack = stack [i :i + limit ] # type: ignore[assignment]
25002501
25012502 stack .reverse ()
25022503 return '' .join (traceback .format_list (stack ))
0 commit comments