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 ):
@@ -1042,7 +1043,7 @@ async def _copy_out(self, copy_stmt: str,
1042
1043
# output is not a path-like object
1043
1044
path = None
1044
1045
1045
- writer = None # type: typing.Optional[Writer ]
1046
+ writer = None # type: typing.Optional[_Writer ]
1046
1047
opened_by_us = False
1047
1048
run_in_executor = self ._loop .run_in_executor
1048
1049
@@ -1633,7 +1634,7 @@ def _set_proxy(self, proxy: typing.Optional['_pool.PoolConnectionProxy']) \
1633
1634
self ._proxy = proxy
1634
1635
1635
1636
def _check_listeners (self ,
1636
- listeners : 'typing._Collection[AnyCallable ]' ,
1637
+ listeners : 'typing._Collection[_AnyCallable ]' ,
1637
1638
listener_type : str ) -> None :
1638
1639
if listeners :
1639
1640
count = len (listeners )
@@ -1736,10 +1737,10 @@ async def _execute(
1736
1737
* ,
1737
1738
return_status : typing_extensions .Literal [True ],
1738
1739
record_class : typing .Optional [typing .Any ] = ...
1739
- ) -> RecordsExtraType :
1740
+ ) -> _RecordsExtraType :
1740
1741
...
1741
1742
1742
- @typing .overload # noqa: F811
1743
+ @typing .overload
1743
1744
async def _execute (
1744
1745
self ,
1745
1746
query : str ,
@@ -1749,10 +1750,10 @@ async def _execute(
1749
1750
* ,
1750
1751
return_status : typing_extensions .Literal [False ] = ...,
1751
1752
record_class : typing .Optional [typing .Any ] = ...
1752
- ) -> RecordsType :
1753
+ ) -> _RecordsType :
1753
1754
...
1754
1755
1755
- @typing .overload # noqa: F811
1756
+ @typing .overload
1756
1757
async def _execute (
1757
1758
self ,
1758
1759
query : str ,
@@ -1762,13 +1763,13 @@ async def _execute(
1762
1763
* ,
1763
1764
return_status : bool ,
1764
1765
record_class : typing .Optional [typing .Any ] = ...
1765
- ) -> typing .Union [RecordsExtraType , RecordsType ]:
1766
+ ) -> typing .Union [_RecordsExtraType , _RecordsType ]:
1766
1767
...
1767
1768
1768
1769
async def _execute (
1769
1770
self ,
1770
1771
query : str ,
1771
- args : typing .Sequence [typing .Any ], # noqa: F811, E501
1772
+ args : typing .Sequence [typing .Any ],
1772
1773
limit : int ,
1773
1774
timeout : typing .Optional [float ],
1774
1775
* ,
@@ -1796,10 +1797,10 @@ async def __execute(
1796
1797
* ,
1797
1798
return_status : typing_extensions .Literal [True ],
1798
1799
record_class : typing .Optional [typing .Any ] = ...
1799
- ) -> typing .Tuple [RecordsExtraType , '_cprotocol.PreparedStatementState' ]:
1800
+ ) -> typing .Tuple [_RecordsExtraType , '_cprotocol.PreparedStatementState' ]:
1800
1801
...
1801
1802
1802
- @typing .overload # noqa: F811
1803
+ @typing .overload
1803
1804
async def __execute (
1804
1805
self ,
1805
1806
query : str ,
@@ -1809,10 +1810,10 @@ async def __execute(
1809
1810
* ,
1810
1811
return_status : typing_extensions .Literal [False ] = ...,
1811
1812
record_class : typing .Optional [typing .Any ] = ...
1812
- ) -> typing .Tuple [RecordsType , '_cprotocol.PreparedStatementState' ]:
1813
+ ) -> typing .Tuple [_RecordsType , '_cprotocol.PreparedStatementState' ]:
1813
1814
...
1814
1815
1815
- @typing .overload # noqa: F811
1816
+ @typing .overload
1816
1817
async def __execute (
1817
1818
self ,
1818
1819
query : str ,
@@ -1823,20 +1824,20 @@ async def __execute(
1823
1824
return_status : bool ,
1824
1825
record_class : typing .Optional [typing .Any ] = ...
1825
1826
) -> 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' ]
1828
1829
]:
1829
1830
...
1830
1831
1831
1832
async def __execute (
1832
1833
self ,
1833
- query : str , # noqa: F811
1834
+ query : str ,
1834
1835
args : typing .Sequence [typing .Any ],
1835
1836
limit : int ,
1836
1837
timeout : typing .Optional [float ],
1837
1838
* ,
1838
1839
return_status : bool = False ,
1839
- record_class : typing .Optional [typing .Any ] = ...
1840
+ record_class : typing .Optional [typing .Any ] = None
1840
1841
) -> typing .Tuple [typing .Any , '_cprotocol.PreparedStatementState' ]:
1841
1842
executor = lambda stmt , timeout : self ._protocol .bind_execute (
1842
1843
stmt , args , '' , limit , return_status , timeout )
@@ -1957,7 +1958,7 @@ async def connect(dsn: typing.Optional[str] = ..., *,
1957
1958
...
1958
1959
1959
1960
1960
- @typing .overload # noqa: F811
1961
+ @typing .overload
1961
1962
async def connect (dsn : typing .Optional [str ] = ..., * ,
1962
1963
host : typing .Optional [connect_utils .HostType ] = ...,
1963
1964
port : typing .Optional [connect_utils .PortType ] = ...,
@@ -1972,14 +1973,14 @@ async def connect(dsn: typing.Optional[str] = ..., *,
1972
1973
max_cacheable_statement_size : int = ...,
1973
1974
command_timeout : typing .Optional [float ] = ...,
1974
1975
ssl : typing .Optional [connect_utils .SSLType ] = ...,
1975
- connection_class : typing .Type [C ],
1976
+ connection_class : typing .Type [_Connection ],
1976
1977
record_class : typing .Optional [typing .Any ] = ...,
1977
1978
server_settings : typing .Optional [
1978
- typing .Dict [str , str ]] = ...) -> C :
1979
+ typing .Dict [str , str ]] = ...) -> _Connection :
1979
1980
...
1980
1981
1981
1982
1982
- async def connect (dsn : typing .Optional [str ] = None , * , # noqa: F811
1983
+ async def connect (dsn : typing .Optional [str ] = None , * ,
1983
1984
host : typing .Optional [connect_utils .HostType ] = None ,
1984
1985
port : typing .Optional [connect_utils .PortType ] = None ,
1985
1986
user : typing .Optional [str ] = None ,
@@ -1993,11 +1994,10 @@ async def connect(dsn: typing.Optional[str] = None, *, # noqa: F811
1993
1994
max_cacheable_statement_size : int = 1024 * 15 ,
1994
1995
command_timeout : typing .Optional [float ] = None ,
1995
1996
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
1998
1998
record_class : typing .Optional [typing .Any ] = protocol .Record ,
1999
1999
server_settings : typing .Optional [
2000
- typing .Dict [str , str ]] = None ) -> C :
2000
+ typing .Dict [str , str ]] = None ) -> _Connection :
2001
2001
r"""A coroutine to establish a connection to a PostgreSQL server.
2002
2002
2003
2003
The connection parameters may be specified either as a connection
0 commit comments