66
77
88import asyncio
9- import typing_extensions
109import asyncpg
1110import collections
1211import collections .abc
3332from . import types
3433from . import utils
3534
35+ # Work around https://github.com/microsoft/pyright/issues/3012
36+ if sys .version_info >= (3 , 8 ):
37+ from typing import Literal
38+ else :
39+ from typing_extensions import Literal
40+
3641if typing .TYPE_CHECKING :
3742 import io
3843 from .protocol import protocol as _cprotocol
3944 from . import pool_connection_proxy as _pool
4045
41-
4246_ConnectionT = typing .TypeVar ('_ConnectionT' , bound = 'Connection[typing.Any]' )
4347_RecordT = typing .TypeVar ('_RecordT' , bound = protocol .Record )
4448_OtherRecordT = typing .TypeVar ('_OtherRecordT' , bound = protocol .Record )
4549
46- _Writer : typing_extensions . TypeAlias = typing .Callable [
50+ _Writer = typing .Callable [
4751 [bytes ],
4852 typing .Coroutine [typing .Any , typing .Any , None ]
4953]
50- _RecordsType : typing_extensions . TypeAlias = typing .List [_RecordT ]
51- _RecordsExtraType : typing_extensions . TypeAlias = typing .Tuple [
54+ _RecordsType = typing .List [_RecordT ]
55+ _RecordsExtraType = typing .Tuple [
5256 _RecordsType [_RecordT ],
5357 bytes ,
5458 bool
5559]
5660
57- OutputType : typing_extensions . TypeAlias = typing .Union [
61+ OutputType = typing .Union [
5862 'os.PathLike[typing.Any]' ,
5963 typing .BinaryIO ,
6064 _Writer
6165]
62- SourceType : typing_extensions . TypeAlias = typing .Union [
66+ SourceType = typing .Union [
6367 'os.PathLike[typing.Any]' ,
6468 typing .BinaryIO ,
6569 typing .AsyncIterable [bytes ]
6670]
6771
68- CopyFormat = compat . Literal ['text' , 'csv' , 'binary' ]
69- PasswordType : typing_extensions . TypeAlias = typing .Union [
72+ CopyFormat = Literal ['text' , 'csv' , 'binary' ]
73+ PasswordType = typing .Union [
7074 str ,
7175 typing .Callable [[], str ],
7276 typing .Callable [[], typing .Awaitable [str ]]
@@ -2133,7 +2137,7 @@ async def _execute(
21332137 limit : int ,
21342138 timeout : typing .Optional [float ],
21352139 * ,
2136- return_status : compat . Literal [False ] = ...,
2140+ return_status : Literal [False ] = ...,
21372141 ignore_custom_codec : bool = ...,
21382142 record_class : None = ...
21392143 ) -> _RecordsType [_RecordT ]:
@@ -2147,7 +2151,7 @@ async def _execute(
21472151 limit : int ,
21482152 timeout : typing .Optional [float ],
21492153 * ,
2150- return_status : compat . Literal [False ] = ...,
2154+ return_status : Literal [False ] = ...,
21512155 ignore_custom_codec : bool = ...,
21522156 record_class : typing .Type [_OtherRecordT ]
21532157 ) -> _RecordsType [_OtherRecordT ]:
@@ -2161,7 +2165,7 @@ async def _execute(
21612165 limit : int ,
21622166 timeout : typing .Optional [float ],
21632167 * ,
2164- return_status : compat . Literal [False ] = ...,
2168+ return_status : Literal [False ] = ...,
21652169 ignore_custom_codec : bool = ...,
21662170 record_class : typing .Optional [typing .Type [_OtherRecordT ]]
21672171 ) -> typing .Union [_RecordsType [_RecordT ], _RecordsType [_OtherRecordT ]]:
@@ -2175,7 +2179,7 @@ async def _execute(
21752179 limit : int ,
21762180 timeout : typing .Optional [float ],
21772181 * ,
2178- return_status : compat . Literal [True ],
2182+ return_status : Literal [True ],
21792183 ignore_custom_codec : bool = ...,
21802184 record_class : None = ...
21812185 ) -> _RecordsExtraType [_RecordT ]:
@@ -2189,7 +2193,7 @@ async def _execute(
21892193 limit : int ,
21902194 timeout : typing .Optional [float ],
21912195 * ,
2192- return_status : compat . Literal [True ],
2196+ return_status : Literal [True ],
21932197 ignore_custom_codec : bool = ...,
21942198 record_class : typing .Type [_OtherRecordT ]
21952199 ) -> _RecordsExtraType [_OtherRecordT ]:
@@ -2226,7 +2230,7 @@ async def __execute(
22262230 limit : int ,
22272231 timeout : typing .Optional [float ],
22282232 * ,
2229- return_status : compat . Literal [False ] = ...,
2233+ return_status : Literal [False ] = ...,
22302234 ignore_custom_codec : bool = ...,
22312235 record_class : None = ...
22322236 ) -> typing .Tuple [
@@ -2243,7 +2247,7 @@ async def __execute(
22432247 limit : int ,
22442248 timeout : typing .Optional [float ],
22452249 * ,
2246- return_status : compat . Literal [False ] = ...,
2250+ return_status : Literal [False ] = ...,
22472251 ignore_custom_codec : bool = ...,
22482252 record_class : typing .Type [_OtherRecordT ]
22492253 ) -> typing .Tuple [
@@ -2260,7 +2264,7 @@ async def __execute(
22602264 limit : int ,
22612265 timeout : typing .Optional [float ],
22622266 * ,
2263- return_status : compat . Literal [True ],
2267+ return_status : Literal [True ],
22642268 ignore_custom_codec : bool = ...,
22652269 record_class : None = ...
22662270 ) -> typing .Tuple [
@@ -2277,7 +2281,7 @@ async def __execute(
22772281 limit : int ,
22782282 timeout : typing .Optional [float ],
22792283 * ,
2280- return_status : compat . Literal [True ],
2284+ return_status : Literal [True ],
22812285 ignore_custom_codec : bool = ...,
22822286 record_class : typing .Type [_OtherRecordT ]
22832287 ) -> typing .Tuple [
0 commit comments