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 ):
@@ -921,7 +922,7 @@ async def _copy_out(self, copy_stmt: str,
921922 # output is not a path-like object
922923 path = None
923924
924- writer = None # type: typing.Optional[Writer ]
925+ writer = None # type: typing.Optional[_Writer ]
925926 opened_by_us = False
926927 run_in_executor = self ._loop .run_in_executor
927928
@@ -1509,7 +1510,7 @@ def _set_proxy(self, proxy: typing.Optional['_pool.PoolConnectionProxy']) \
15091510 self ._proxy = proxy
15101511
15111512 def _check_listeners (self ,
1512- listeners : 'typing._Collection[AnyCallable ]' ,
1513+ listeners : 'typing._Collection[_AnyCallable ]' ,
15131514 listener_type : str ) -> None :
15141515 if listeners :
15151516 count = len (listeners )
@@ -1606,24 +1607,24 @@ async def reload_schema_state(self) -> None:
16061607 async def _execute (self , query : str , args : typing .Sequence [typing .Any ],
16071608 limit : int , timeout : typing .Optional [float ],
16081609 return_status : typing_extensions .Literal [True ]) \
1609- -> RecordsExtraType :
1610+ -> _RecordsExtraType :
16101611 ...
16111612
1612- @typing .overload # noqa: F811
1613+ @typing .overload
16131614 async def _execute (self , query : str , args : typing .Sequence [typing .Any ],
16141615 limit : int , timeout : typing .Optional [float ],
16151616 return_status : typing_extensions .Literal [False ] = ...) \
1616- -> RecordsType :
1617+ -> _RecordsType :
16171618 ...
16181619
1619- @typing .overload # noqa: F811
1620+ @typing .overload
16201621 async def _execute (self , query : str , args : typing .Sequence [typing .Any ],
16211622 limit : int , timeout : typing .Optional [float ],
16221623 return_status : bool ) \
1623- -> typing .Union [RecordsExtraType , RecordsType ]:
1624+ -> typing .Union [_RecordsExtraType , _RecordsType ]:
16241625 ...
16251626
1626- async def _execute (self , query : str , args : typing .Sequence [typing .Any ], # noqa: F811, E501
1627+ async def _execute (self , query : str , args : typing .Sequence [typing .Any ],
16271628 limit : int , timeout : typing .Optional [float ],
16281629 return_status : bool = False ) -> typing .Any :
16291630 with self ._stmt_exclusive_section :
@@ -1635,29 +1636,29 @@ async def _execute(self, query: str, args: typing.Sequence[typing.Any], # noqa:
16351636 async def __execute (self , query : str , args : typing .Sequence [typing .Any ],
16361637 limit : int , timeout : typing .Optional [float ],
16371638 return_status : typing_extensions .Literal [True ]) \
1638- -> typing .Tuple [RecordsExtraType ,
1639+ -> typing .Tuple [_RecordsExtraType ,
16391640 '_cprotocol.PreparedStatementState' ]:
16401641 ...
16411642
1642- @typing .overload # noqa: F811
1643+ @typing .overload
16431644 async def __execute (self , query : str , args : typing .Sequence [typing .Any ],
16441645 limit : int , timeout : typing .Optional [float ],
16451646 return_status : typing_extensions .Literal [
16461647 False ] = ...) \
1647- -> typing .Tuple [RecordsType , '_cprotocol.PreparedStatementState' ]:
1648+ -> typing .Tuple [_RecordsType , '_cprotocol.PreparedStatementState' ]:
16481649 ...
16491650
1650- @typing .overload # noqa: F811
1651+ @typing .overload
16511652 async def __execute (self , query : str , args : typing .Sequence [typing .Any ],
16521653 limit : int , timeout : typing .Optional [float ],
16531654 return_status : bool ) \
1654- -> typing .Union [typing .Tuple [RecordsExtraType ,
1655+ -> typing .Union [typing .Tuple [_RecordsExtraType ,
16551656 '_cprotocol.PreparedStatementState' ],
1656- typing .Tuple [RecordsType ,
1657+ typing .Tuple [_RecordsType ,
16571658 '_cprotocol.PreparedStatementState' ]]:
16581659 ...
16591660
1660- async def __execute (self , query : str , # noqa: F811
1661+ async def __execute (self , query : str ,
16611662 args : typing .Sequence [typing .Any ],
16621663 limit : int , timeout : typing .Optional [float ],
16631664 return_status : bool = False ) -> typing .Tuple [
@@ -1762,7 +1763,7 @@ async def connect(dsn: typing.Optional[str] = ..., *,
17621763 ...
17631764
17641765
1765- @typing .overload # noqa: F811
1766+ @typing .overload
17661767async def connect (dsn : typing .Optional [str ] = ..., * ,
17671768 host : typing .Optional [connect_utils .HostType ] = ...,
17681769 port : typing .Optional [connect_utils .PortType ] = ...,
@@ -1777,13 +1778,13 @@ async def connect(dsn: typing.Optional[str] = ..., *,
17771778 max_cacheable_statement_size : int = ...,
17781779 command_timeout : typing .Optional [float ] = ...,
17791780 ssl : typing .Optional [connect_utils .SSLType ] = ...,
1780- connection_class : typing .Type [C ],
1781+ connection_class : typing .Type [_Connection ],
17811782 server_settings : typing .Optional [
1782- typing .Dict [str , str ]] = ...) -> C :
1783+ typing .Dict [str , str ]] = ...) -> _Connection :
17831784 ...
17841785
17851786
1786- async def connect (dsn : typing .Optional [str ] = None , * , # noqa: F811
1787+ async def connect (dsn : typing .Optional [str ] = None , * ,
17871788 host : typing .Optional [connect_utils .HostType ] = None ,
17881789 port : typing .Optional [connect_utils .PortType ] = None ,
17891790 user : typing .Optional [str ] = None ,
@@ -1797,10 +1798,9 @@ async def connect(dsn: typing.Optional[str] = None, *, # noqa: F811
17971798 max_cacheable_statement_size : int = 1024 * 15 ,
17981799 command_timeout : typing .Optional [float ] = None ,
17991800 ssl : typing .Optional [connect_utils .SSLType ] = None ,
1800- connection_class : typing .Type [C ] = \
1801- Connection , # type: ignore
1801+ connection_class : typing .Type [_Connection ] = Connection , # type: ignore # noqa: E501
18021802 server_settings : typing .Optional [
1803- typing .Dict [str , str ]] = None ) -> C :
1803+ typing .Dict [str , str ]] = None ) -> _Connection :
18041804 r"""A coroutine to establish a connection to a PostgreSQL server.
18051805
18061806 The connection parameters may be specified either as a connection
0 commit comments