3535 from . import types
3636
3737
38- C = typing .TypeVar ('C' , bound = 'Connection' )
39- Writer = typing .Callable [[bytes ],
40- typing .Coroutine [typing .Any , typing .Any , None ]]
38+ _Connection = typing .TypeVar ('_Connection' , bound = 'Connection' )
39+ _Writer = typing .Callable [[bytes ],
40+ typing .Coroutine [typing .Any , typing .Any , None ]]
41+ _RecordsType = typing .List ['_cprotocol.Record' ]
42+ _RecordsExtraType = typing .Tuple [_RecordsType , bytes , bool ]
43+ _AnyCallable = typing .Callable [..., typing .Any ]
44+
4145OutputType = typing .Union [typing .AnyStr ,
4246 compat .PathLike [typing .AnyStr ],
4347 typing .IO [typing .AnyStr ],
44- Writer ]
48+ _Writer ]
4549SourceType = typing .Union [typing .AnyStr ,
4650 compat .PathLike [typing .AnyStr ],
4751 typing .IO [typing .AnyStr ],
4852 typing .AsyncIterable [bytes ]]
4953
5054CopyFormat = typing_extensions .Literal ['text' , 'csv' , 'binary' ]
5155PasswordType = typing .Union [str , typing .Callable [[], str ]]
52- RecordsType = typing .List ['_cprotocol.Record' ]
53- RecordsExtraType = typing .Tuple [RecordsType , bytes , bool ]
54- AnyCallable = typing .Callable [..., typing .Any ]
5556
5657
5758class Listener (typing_extensions .Protocol ):
@@ -890,7 +891,7 @@ async def _copy_out(self, copy_stmt: str,
890891 # output is not a path-like object
891892 path = None
892893
893- writer = None # type: typing.Optional[Writer ]
894+ writer = None # type: typing.Optional[_Writer ]
894895 opened_by_us = False
895896 run_in_executor = self ._loop .run_in_executor
896897
@@ -1458,7 +1459,7 @@ def _set_proxy(self, proxy: typing.Optional['_pool.PoolConnectionProxy']) \
14581459 self ._proxy = proxy
14591460
14601461 def _check_listeners (self ,
1461- listeners : 'typing._Collection[AnyCallable ]' ,
1462+ listeners : 'typing._Collection[_AnyCallable ]' ,
14621463 listener_type : str ) -> None :
14631464 if listeners :
14641465 count = len (listeners )
@@ -1555,24 +1556,24 @@ async def reload_schema_state(self) -> None:
15551556 async def _execute (self , query : str , args : typing .Sequence [typing .Any ],
15561557 limit : int , timeout : typing .Optional [float ],
15571558 return_status : typing_extensions .Literal [True ]) \
1558- -> RecordsExtraType :
1559+ -> _RecordsExtraType :
15591560 ...
15601561
1561- @typing .overload # noqa: F811
1562+ @typing .overload
15621563 async def _execute (self , query : str , args : typing .Sequence [typing .Any ],
15631564 limit : int , timeout : typing .Optional [float ],
15641565 return_status : typing_extensions .Literal [False ] = ...) \
1565- -> RecordsType :
1566+ -> _RecordsType :
15661567 ...
15671568
1568- @typing .overload # noqa: F811
1569+ @typing .overload
15691570 async def _execute (self , query : str , args : typing .Sequence [typing .Any ],
15701571 limit : int , timeout : typing .Optional [float ],
15711572 return_status : bool ) \
1572- -> typing .Union [RecordsExtraType , RecordsType ]:
1573+ -> typing .Union [_RecordsExtraType , _RecordsType ]:
15731574 ...
15741575
1575- async def _execute (self , query : str , args : typing .Sequence [typing .Any ], # noqa: F811, E501
1576+ async def _execute (self , query : str , args : typing .Sequence [typing .Any ],
15761577 limit : int , timeout : typing .Optional [float ],
15771578 return_status : bool = False ) -> typing .Any :
15781579 with self ._stmt_exclusive_section :
@@ -1584,29 +1585,29 @@ async def _execute(self, query: str, args: typing.Sequence[typing.Any], # noqa:
15841585 async def __execute (self , query : str , args : typing .Sequence [typing .Any ],
15851586 limit : int , timeout : typing .Optional [float ],
15861587 return_status : typing_extensions .Literal [True ]) \
1587- -> typing .Tuple [RecordsExtraType ,
1588+ -> typing .Tuple [_RecordsExtraType ,
15881589 '_cprotocol.PreparedStatementState' ]:
15891590 ...
15901591
1591- @typing .overload # noqa: F811
1592+ @typing .overload
15921593 async def __execute (self , query : str , args : typing .Sequence [typing .Any ],
15931594 limit : int , timeout : typing .Optional [float ],
15941595 return_status : typing_extensions .Literal [
15951596 False ] = ...) \
1596- -> typing .Tuple [RecordsType , '_cprotocol.PreparedStatementState' ]:
1597+ -> typing .Tuple [_RecordsType , '_cprotocol.PreparedStatementState' ]:
15971598 ...
15981599
1599- @typing .overload # noqa: F811
1600+ @typing .overload
16001601 async def __execute (self , query : str , args : typing .Sequence [typing .Any ],
16011602 limit : int , timeout : typing .Optional [float ],
16021603 return_status : bool ) \
1603- -> typing .Union [typing .Tuple [RecordsExtraType ,
1604+ -> typing .Union [typing .Tuple [_RecordsExtraType ,
16041605 '_cprotocol.PreparedStatementState' ],
1605- typing .Tuple [RecordsType ,
1606+ typing .Tuple [_RecordsType ,
16061607 '_cprotocol.PreparedStatementState' ]]:
16071608 ...
16081609
1609- async def __execute (self , query : str , # noqa: F811
1610+ async def __execute (self , query : str ,
16101611 args : typing .Sequence [typing .Any ],
16111612 limit : int , timeout : typing .Optional [float ],
16121613 return_status : bool = False ) -> typing .Tuple [
@@ -1711,7 +1712,7 @@ async def connect(dsn: typing.Optional[str] = ..., *,
17111712 ...
17121713
17131714
1714- @typing .overload # noqa: F811
1715+ @typing .overload
17151716async def connect (dsn : typing .Optional [str ] = ..., * ,
17161717 host : typing .Optional [connect_utils .HostType ] = ...,
17171718 port : typing .Optional [connect_utils .PortType ] = ...,
@@ -1726,13 +1727,13 @@ async def connect(dsn: typing.Optional[str] = ..., *,
17261727 max_cacheable_statement_size : int = ...,
17271728 command_timeout : typing .Optional [float ] = ...,
17281729 ssl : typing .Optional [connect_utils .SSLType ] = ...,
1729- connection_class : typing .Type [C ],
1730+ connection_class : typing .Type [_Connection ],
17301731 server_settings : typing .Optional [
1731- typing .Dict [str , str ]] = ...) -> C :
1732+ typing .Dict [str , str ]] = ...) -> _Connection :
17321733 ...
17331734
17341735
1735- async def connect (dsn : typing .Optional [str ] = None , * , # noqa: F811
1736+ async def connect (dsn : typing .Optional [str ] = None , * ,
17361737 host : typing .Optional [connect_utils .HostType ] = None ,
17371738 port : typing .Optional [connect_utils .PortType ] = None ,
17381739 user : typing .Optional [str ] = None ,
@@ -1746,10 +1747,9 @@ async def connect(dsn: typing.Optional[str] = None, *, # noqa: F811
17461747 max_cacheable_statement_size : int = 1024 * 15 ,
17471748 command_timeout : typing .Optional [float ] = None ,
17481749 ssl : typing .Optional [connect_utils .SSLType ] = None ,
1749- connection_class : typing .Type [C ] = \
1750- Connection , # type: ignore
1750+ connection_class : typing .Type [_Connection ] = Connection , # type: ignore # noqa: E501
17511751 server_settings : typing .Optional [
1752- typing .Dict [str , str ]] = None ) -> C :
1752+ typing .Dict [str , str ]] = None ) -> _Connection :
17531753 r"""A coroutine to establish a connection to a PostgreSQL server.
17541754
17551755 The connection parameters may be specified either as a connection
0 commit comments