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 ):
@@ -1082,7 +1083,7 @@ async def _copy_out(self, copy_stmt: str,
10821083 # output is not a path-like object
10831084 path = None
10841085
1085- writer = None # type: typing.Optional[Writer ]
1086+ writer = None # type: typing.Optional[_Writer ]
10861087 opened_by_us = False
10871088 run_in_executor = self ._loop .run_in_executor
10881089
@@ -1658,7 +1659,7 @@ def _set_proxy(self, proxy: typing.Optional['_pool.PoolConnectionProxy']) \
16581659 self ._proxy = proxy
16591660
16601661 def _check_listeners (self ,
1661- listeners : 'typing._Collection[AnyCallable ]' ,
1662+ listeners : 'typing._Collection[_AnyCallable ]' ,
16621663 listener_type : str ) -> None :
16631664 if listeners :
16641665 count = len (listeners )
@@ -1762,10 +1763,10 @@ async def _execute(
17621763 return_status : typing_extensions .Literal [True ],
17631764 ignore_custom_codec : bool = ...,
17641765 record_class : typing .Optional [typing .Any ] = ...
1765- ) -> RecordsExtraType :
1766+ ) -> _RecordsExtraType :
17661767 ...
17671768
1768- @typing .overload # noqa: F811
1769+ @typing .overload
17691770 async def _execute (
17701771 self ,
17711772 query : str ,
@@ -1776,10 +1777,10 @@ async def _execute(
17761777 return_status : typing_extensions .Literal [False ] = ...,
17771778 ignore_custom_codec : bool = ...,
17781779 record_class : typing .Optional [typing .Any ] = ...
1779- ) -> RecordsType :
1780+ ) -> _RecordsType :
17801781 ...
17811782
1782- @typing .overload # noqa: F811
1783+ @typing .overload
17831784 async def _execute (
17841785 self ,
17851786 query : str ,
@@ -1790,13 +1791,13 @@ async def _execute(
17901791 return_status : bool ,
17911792 ignore_custom_codec : bool = ...,
17921793 record_class : typing .Optional [typing .Any ] = ...
1793- ) -> typing .Union [RecordsExtraType , RecordsType ]:
1794+ ) -> typing .Union [_RecordsExtraType , _RecordsType ]:
17941795 ...
17951796
17961797 async def _execute (
17971798 self ,
17981799 query : str ,
1799- args : typing .Sequence [typing .Any ], # noqa: F811, E501
1800+ args : typing .Sequence [typing .Any ],
18001801 limit : int ,
18011802 timeout : typing .Optional [float ],
18021803 * ,
@@ -1827,10 +1828,10 @@ async def __execute(
18271828 return_status : typing_extensions .Literal [True ],
18281829 ignore_custom_codec : bool = ...,
18291830 record_class : typing .Optional [typing .Any ] = ...
1830- ) -> typing .Tuple [RecordsExtraType , '_cprotocol.PreparedStatementState' ]:
1831+ ) -> typing .Tuple [_RecordsExtraType , '_cprotocol.PreparedStatementState' ]:
18311832 ...
18321833
1833- @typing .overload # noqa: F811
1834+ @typing .overload
18341835 async def __execute (
18351836 self ,
18361837 query : str ,
@@ -1841,10 +1842,10 @@ async def __execute(
18411842 return_status : typing_extensions .Literal [False ] = ...,
18421843 ignore_custom_codec : bool = ...,
18431844 record_class : typing .Optional [typing .Any ] = ...
1844- ) -> typing .Tuple [RecordsType , '_cprotocol.PreparedStatementState' ]:
1845+ ) -> typing .Tuple [_RecordsType , '_cprotocol.PreparedStatementState' ]:
18451846 ...
18461847
1847- @typing .overload # noqa: F811
1848+ @typing .overload
18481849 async def __execute (
18491850 self ,
18501851 query : str ,
@@ -1856,21 +1857,21 @@ async def __execute(
18561857 ignore_custom_codec : bool = ...,
18571858 record_class : typing .Optional [typing .Any ] = ...
18581859 ) -> typing .Union [
1859- typing .Tuple [RecordsExtraType , '_cprotocol.PreparedStatementState' ],
1860- typing .Tuple [RecordsType , '_cprotocol.PreparedStatementState' ]
1860+ typing .Tuple [_RecordsExtraType , '_cprotocol.PreparedStatementState' ],
1861+ typing .Tuple [_RecordsType , '_cprotocol.PreparedStatementState' ]
18611862 ]:
18621863 ...
18631864
18641865 async def __execute (
18651866 self ,
1866- query : str , # noqa: F811
1867+ query : str ,
18671868 args : typing .Sequence [typing .Any ],
18681869 limit : int ,
18691870 timeout : typing .Optional [float ],
18701871 * ,
18711872 return_status : bool = False ,
18721873 ignore_custom_codec : bool = False ,
1873- record_class : typing .Optional [typing .Any ] = ...
1874+ record_class : typing .Optional [typing .Any ] = None
18741875 ) -> typing .Tuple [typing .Any , '_cprotocol.PreparedStatementState' ]:
18751876 executor = lambda stmt , timeout : self ._protocol .bind_execute (
18761877 stmt , args , '' , limit , return_status , timeout )
@@ -1995,7 +1996,7 @@ async def connect(dsn: typing.Optional[str] = ..., *,
19951996 ...
19961997
19971998
1998- @typing .overload # noqa: F811
1999+ @typing .overload
19992000async def connect (dsn : typing .Optional [str ] = ..., * ,
20002001 host : typing .Optional [connect_utils .HostType ] = ...,
20012002 port : typing .Optional [connect_utils .PortType ] = ...,
@@ -2010,14 +2011,14 @@ async def connect(dsn: typing.Optional[str] = ..., *,
20102011 max_cacheable_statement_size : int = ...,
20112012 command_timeout : typing .Optional [float ] = ...,
20122013 ssl : typing .Optional [connect_utils .SSLType ] = ...,
2013- connection_class : typing .Type [C ],
2014+ connection_class : typing .Type [_Connection ],
20142015 record_class : typing .Optional [typing .Any ] = ...,
20152016 server_settings : typing .Optional [
2016- typing .Dict [str , str ]] = ...) -> C :
2017+ typing .Dict [str , str ]] = ...) -> _Connection :
20172018 ...
20182019
20192020
2020- async def connect (dsn : typing .Optional [str ] = None , * , # noqa: F811
2021+ async def connect (dsn : typing .Optional [str ] = None , * ,
20212022 host : typing .Optional [connect_utils .HostType ] = None ,
20222023 port : typing .Optional [connect_utils .PortType ] = None ,
20232024 user : typing .Optional [str ] = None ,
@@ -2031,11 +2032,10 @@ async def connect(dsn: typing.Optional[str] = None, *, # noqa: F811
20312032 max_cacheable_statement_size : int = 1024 * 15 ,
20322033 command_timeout : typing .Optional [float ] = None ,
20332034 ssl : typing .Optional [connect_utils .SSLType ] = None ,
2034- connection_class : typing .Type [C ] = \
2035- Connection , # type: ignore
2035+ connection_class : typing .Type [_Connection ] = Connection , # type: ignore # noqa: E501
20362036 record_class : typing .Optional [typing .Any ] = protocol .Record ,
20372037 server_settings : typing .Optional [
2038- typing .Dict [str , str ]] = None ) -> C :
2038+ typing .Dict [str , str ]] = None ) -> _Connection :
20392039 r"""A coroutine to establish a connection to a PostgreSQL server.
20402040
20412041 The connection parameters may be specified either as a connection
0 commit comments