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 ):
@@ -1042,7 +1043,7 @@ async def _copy_out(self, copy_stmt: str,
10421043 # output is not a path-like object
10431044 path = None
10441045
1045- writer = None # type: typing.Optional[Writer ]
1046+ writer = None # type: typing.Optional[_Writer ]
10461047 opened_by_us = False
10471048 run_in_executor = self ._loop .run_in_executor
10481049
@@ -1633,7 +1634,7 @@ def _set_proxy(self, proxy: typing.Optional['_pool.PoolConnectionProxy']) \
16331634 self ._proxy = proxy
16341635
16351636 def _check_listeners (self ,
1636- listeners : 'typing._Collection[AnyCallable ]' ,
1637+ listeners : 'typing._Collection[_AnyCallable ]' ,
16371638 listener_type : str ) -> None :
16381639 if listeners :
16391640 count = len (listeners )
@@ -1736,10 +1737,10 @@ async def _execute(
17361737 * ,
17371738 return_status : typing_extensions .Literal [True ],
17381739 record_class : typing .Optional [typing .Any ] = ...
1739- ) -> RecordsExtraType :
1740+ ) -> _RecordsExtraType :
17401741 ...
17411742
1742- @typing .overload # noqa: F811
1743+ @typing .overload
17431744 async def _execute (
17441745 self ,
17451746 query : str ,
@@ -1749,10 +1750,10 @@ async def _execute(
17491750 * ,
17501751 return_status : typing_extensions .Literal [False ] = ...,
17511752 record_class : typing .Optional [typing .Any ] = ...
1752- ) -> RecordsType :
1753+ ) -> _RecordsType :
17531754 ...
17541755
1755- @typing .overload # noqa: F811
1756+ @typing .overload
17561757 async def _execute (
17571758 self ,
17581759 query : str ,
@@ -1762,13 +1763,13 @@ async def _execute(
17621763 * ,
17631764 return_status : bool ,
17641765 record_class : typing .Optional [typing .Any ] = ...
1765- ) -> typing .Union [RecordsExtraType , RecordsType ]:
1766+ ) -> typing .Union [_RecordsExtraType , _RecordsType ]:
17661767 ...
17671768
17681769 async def _execute (
17691770 self ,
17701771 query : str ,
1771- args : typing .Sequence [typing .Any ], # noqa: F811, E501
1772+ args : typing .Sequence [typing .Any ],
17721773 limit : int ,
17731774 timeout : typing .Optional [float ],
17741775 * ,
@@ -1796,10 +1797,10 @@ async def __execute(
17961797 * ,
17971798 return_status : typing_extensions .Literal [True ],
17981799 record_class : typing .Optional [typing .Any ] = ...
1799- ) -> typing .Tuple [RecordsExtraType , '_cprotocol.PreparedStatementState' ]:
1800+ ) -> typing .Tuple [_RecordsExtraType , '_cprotocol.PreparedStatementState' ]:
18001801 ...
18011802
1802- @typing .overload # noqa: F811
1803+ @typing .overload
18031804 async def __execute (
18041805 self ,
18051806 query : str ,
@@ -1809,10 +1810,10 @@ async def __execute(
18091810 * ,
18101811 return_status : typing_extensions .Literal [False ] = ...,
18111812 record_class : typing .Optional [typing .Any ] = ...
1812- ) -> typing .Tuple [RecordsType , '_cprotocol.PreparedStatementState' ]:
1813+ ) -> typing .Tuple [_RecordsType , '_cprotocol.PreparedStatementState' ]:
18131814 ...
18141815
1815- @typing .overload # noqa: F811
1816+ @typing .overload
18161817 async def __execute (
18171818 self ,
18181819 query : str ,
@@ -1823,20 +1824,20 @@ async def __execute(
18231824 return_status : bool ,
18241825 record_class : typing .Optional [typing .Any ] = ...
18251826 ) -> typing .Union [
1826- typing .Tuple [RecordsExtraType , '_cprotocol.PreparedStatementState' ],
1827- typing .Tuple [RecordsType , '_cprotocol.PreparedStatementState' ]
1827+ typing .Tuple [_RecordsExtraType , '_cprotocol.PreparedStatementState' ],
1828+ typing .Tuple [_RecordsType , '_cprotocol.PreparedStatementState' ]
18281829 ]:
18291830 ...
18301831
18311832 async def __execute (
18321833 self ,
1833- query : str , # noqa: F811
1834+ query : str ,
18341835 args : typing .Sequence [typing .Any ],
18351836 limit : int ,
18361837 timeout : typing .Optional [float ],
18371838 * ,
18381839 return_status : bool = False ,
1839- record_class : typing .Optional [typing .Any ] = ...
1840+ record_class : typing .Optional [typing .Any ] = None
18401841 ) -> typing .Tuple [typing .Any , '_cprotocol.PreparedStatementState' ]:
18411842 executor = lambda stmt , timeout : self ._protocol .bind_execute (
18421843 stmt , args , '' , limit , return_status , timeout )
@@ -1957,7 +1958,7 @@ async def connect(dsn: typing.Optional[str] = ..., *,
19571958 ...
19581959
19591960
1960- @typing .overload # noqa: F811
1961+ @typing .overload
19611962async def connect (dsn : typing .Optional [str ] = ..., * ,
19621963 host : typing .Optional [connect_utils .HostType ] = ...,
19631964 port : typing .Optional [connect_utils .PortType ] = ...,
@@ -1972,14 +1973,14 @@ async def connect(dsn: typing.Optional[str] = ..., *,
19721973 max_cacheable_statement_size : int = ...,
19731974 command_timeout : typing .Optional [float ] = ...,
19741975 ssl : typing .Optional [connect_utils .SSLType ] = ...,
1975- connection_class : typing .Type [C ],
1976+ connection_class : typing .Type [_Connection ],
19761977 record_class : typing .Optional [typing .Any ] = ...,
19771978 server_settings : typing .Optional [
1978- typing .Dict [str , str ]] = ...) -> C :
1979+ typing .Dict [str , str ]] = ...) -> _Connection :
19791980 ...
19801981
19811982
1982- async def connect (dsn : typing .Optional [str ] = None , * , # noqa: F811
1983+ async def connect (dsn : typing .Optional [str ] = None , * ,
19831984 host : typing .Optional [connect_utils .HostType ] = None ,
19841985 port : typing .Optional [connect_utils .PortType ] = None ,
19851986 user : typing .Optional [str ] = None ,
@@ -1993,11 +1994,10 @@ async def connect(dsn: typing.Optional[str] = None, *, # noqa: F811
19931994 max_cacheable_statement_size : int = 1024 * 15 ,
19941995 command_timeout : typing .Optional [float ] = None ,
19951996 ssl : typing .Optional [connect_utils .SSLType ] = None ,
1996- connection_class : typing .Type [C ] = \
1997- Connection , # type: ignore
1997+ connection_class : typing .Type [_Connection ] = Connection , # type: ignore # noqa: E501
19981998 record_class : typing .Optional [typing .Any ] = protocol .Record ,
19991999 server_settings : typing .Optional [
2000- typing .Dict [str , str ]] = None ) -> C :
2000+ typing .Dict [str , str ]] = None ) -> _Connection :
20012001 r"""A coroutine to establish a connection to a PostgreSQL server.
20022002
20032003 The connection parameters may be specified either as a connection
0 commit comments