35
35
from . import types
36
36
37
37
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
+
41
45
OutputType = typing .Union [typing .AnyStr ,
42
46
compat .PathLike [typing .AnyStr ],
43
47
typing .IO [typing .AnyStr ],
44
- Writer ]
48
+ _Writer ]
45
49
SourceType = typing .Union [typing .AnyStr ,
46
50
compat .PathLike [typing .AnyStr ],
47
51
typing .IO [typing .AnyStr ],
48
52
typing .AsyncIterable [bytes ]]
49
53
50
54
CopyFormat = typing_extensions .Literal ['text' , 'csv' , 'binary' ]
51
55
PasswordType = 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 ]
55
56
56
57
57
58
class Listener (typing_extensions .Protocol ):
@@ -1082,7 +1083,7 @@ async def _copy_out(self, copy_stmt: str,
1082
1083
# output is not a path-like object
1083
1084
path = None
1084
1085
1085
- writer = None # type: typing.Optional[Writer ]
1086
+ writer = None # type: typing.Optional[_Writer ]
1086
1087
opened_by_us = False
1087
1088
run_in_executor = self ._loop .run_in_executor
1088
1089
@@ -1658,7 +1659,7 @@ def _set_proxy(self, proxy: typing.Optional['_pool.PoolConnectionProxy']) \
1658
1659
self ._proxy = proxy
1659
1660
1660
1661
def _check_listeners (self ,
1661
- listeners : 'typing._Collection[AnyCallable ]' ,
1662
+ listeners : 'typing._Collection[_AnyCallable ]' ,
1662
1663
listener_type : str ) -> None :
1663
1664
if listeners :
1664
1665
count = len (listeners )
@@ -1762,10 +1763,10 @@ async def _execute(
1762
1763
return_status : typing_extensions .Literal [True ],
1763
1764
ignore_custom_codec : bool = ...,
1764
1765
record_class : typing .Optional [typing .Any ] = ...
1765
- ) -> RecordsExtraType :
1766
+ ) -> _RecordsExtraType :
1766
1767
...
1767
1768
1768
- @typing .overload # noqa: F811
1769
+ @typing .overload
1769
1770
async def _execute (
1770
1771
self ,
1771
1772
query : str ,
@@ -1776,10 +1777,10 @@ async def _execute(
1776
1777
return_status : typing_extensions .Literal [False ] = ...,
1777
1778
ignore_custom_codec : bool = ...,
1778
1779
record_class : typing .Optional [typing .Any ] = ...
1779
- ) -> RecordsType :
1780
+ ) -> _RecordsType :
1780
1781
...
1781
1782
1782
- @typing .overload # noqa: F811
1783
+ @typing .overload
1783
1784
async def _execute (
1784
1785
self ,
1785
1786
query : str ,
@@ -1790,13 +1791,13 @@ async def _execute(
1790
1791
return_status : bool ,
1791
1792
ignore_custom_codec : bool = ...,
1792
1793
record_class : typing .Optional [typing .Any ] = ...
1793
- ) -> typing .Union [RecordsExtraType , RecordsType ]:
1794
+ ) -> typing .Union [_RecordsExtraType , _RecordsType ]:
1794
1795
...
1795
1796
1796
1797
async def _execute (
1797
1798
self ,
1798
1799
query : str ,
1799
- args : typing .Sequence [typing .Any ], # noqa: F811, E501
1800
+ args : typing .Sequence [typing .Any ],
1800
1801
limit : int ,
1801
1802
timeout : typing .Optional [float ],
1802
1803
* ,
@@ -1827,10 +1828,10 @@ async def __execute(
1827
1828
return_status : typing_extensions .Literal [True ],
1828
1829
ignore_custom_codec : bool = ...,
1829
1830
record_class : typing .Optional [typing .Any ] = ...
1830
- ) -> typing .Tuple [RecordsExtraType , '_cprotocol.PreparedStatementState' ]:
1831
+ ) -> typing .Tuple [_RecordsExtraType , '_cprotocol.PreparedStatementState' ]:
1831
1832
...
1832
1833
1833
- @typing .overload # noqa: F811
1834
+ @typing .overload
1834
1835
async def __execute (
1835
1836
self ,
1836
1837
query : str ,
@@ -1841,10 +1842,10 @@ async def __execute(
1841
1842
return_status : typing_extensions .Literal [False ] = ...,
1842
1843
ignore_custom_codec : bool = ...,
1843
1844
record_class : typing .Optional [typing .Any ] = ...
1844
- ) -> typing .Tuple [RecordsType , '_cprotocol.PreparedStatementState' ]:
1845
+ ) -> typing .Tuple [_RecordsType , '_cprotocol.PreparedStatementState' ]:
1845
1846
...
1846
1847
1847
- @typing .overload # noqa: F811
1848
+ @typing .overload
1848
1849
async def __execute (
1849
1850
self ,
1850
1851
query : str ,
@@ -1856,21 +1857,21 @@ async def __execute(
1856
1857
ignore_custom_codec : bool = ...,
1857
1858
record_class : typing .Optional [typing .Any ] = ...
1858
1859
) -> 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' ]
1861
1862
]:
1862
1863
...
1863
1864
1864
1865
async def __execute (
1865
1866
self ,
1866
- query : str , # noqa: F811
1867
+ query : str ,
1867
1868
args : typing .Sequence [typing .Any ],
1868
1869
limit : int ,
1869
1870
timeout : typing .Optional [float ],
1870
1871
* ,
1871
1872
return_status : bool = False ,
1872
1873
ignore_custom_codec : bool = False ,
1873
- record_class : typing .Optional [typing .Any ] = ...
1874
+ record_class : typing .Optional [typing .Any ] = None
1874
1875
) -> typing .Tuple [typing .Any , '_cprotocol.PreparedStatementState' ]:
1875
1876
executor = lambda stmt , timeout : self ._protocol .bind_execute (
1876
1877
stmt , args , '' , limit , return_status , timeout )
@@ -1995,7 +1996,7 @@ async def connect(dsn: typing.Optional[str] = ..., *,
1995
1996
...
1996
1997
1997
1998
1998
- @typing .overload # noqa: F811
1999
+ @typing .overload
1999
2000
async def connect (dsn : typing .Optional [str ] = ..., * ,
2000
2001
host : typing .Optional [connect_utils .HostType ] = ...,
2001
2002
port : typing .Optional [connect_utils .PortType ] = ...,
@@ -2010,14 +2011,14 @@ async def connect(dsn: typing.Optional[str] = ..., *,
2010
2011
max_cacheable_statement_size : int = ...,
2011
2012
command_timeout : typing .Optional [float ] = ...,
2012
2013
ssl : typing .Optional [connect_utils .SSLType ] = ...,
2013
- connection_class : typing .Type [C ],
2014
+ connection_class : typing .Type [_Connection ],
2014
2015
record_class : typing .Optional [typing .Any ] = ...,
2015
2016
server_settings : typing .Optional [
2016
- typing .Dict [str , str ]] = ...) -> C :
2017
+ typing .Dict [str , str ]] = ...) -> _Connection :
2017
2018
...
2018
2019
2019
2020
2020
- async def connect (dsn : typing .Optional [str ] = None , * , # noqa: F811
2021
+ async def connect (dsn : typing .Optional [str ] = None , * ,
2021
2022
host : typing .Optional [connect_utils .HostType ] = None ,
2022
2023
port : typing .Optional [connect_utils .PortType ] = None ,
2023
2024
user : typing .Optional [str ] = None ,
@@ -2031,11 +2032,10 @@ async def connect(dsn: typing.Optional[str] = None, *, # noqa: F811
2031
2032
max_cacheable_statement_size : int = 1024 * 15 ,
2032
2033
command_timeout : typing .Optional [float ] = None ,
2033
2034
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
2036
2036
record_class : typing .Optional [typing .Any ] = protocol .Record ,
2037
2037
server_settings : typing .Optional [
2038
- typing .Dict [str , str ]] = None ) -> C :
2038
+ typing .Dict [str , str ]] = None ) -> _Connection :
2039
2039
r"""A coroutine to establish a connection to a PostgreSQL server.
2040
2040
2041
2041
The connection parameters may be specified either as a connection
0 commit comments