1
1
from typing import Any
2
2
from typing import Callable
3
+ from typing import Generator
3
4
from typing import Mapping
5
+ from typing import NoReturn
4
6
from typing import Optional
7
+ from typing import TypeVar
5
8
6
- from .base import ProxyComparable as ProxyComparable
7
- from .base import StartableContext as StartableContext
8
- from .result import AsyncResult as AsyncResult
9
- from ... import exc as exc
10
- from ... import util as util
11
- from ...engine import Result as Result
12
- from ...engine import Transaction as Transaction
13
- from ...future import Connection as Connection
14
- from ...future import Engine as Engine
15
- from ...sql import Executable as Executable
16
- from ...util .concurrency import greenlet_spawn as greenlet_spawn
9
+ from .base import ProxyComparable
10
+ from .base import StartableContext
11
+ from .result import AsyncResult
12
+ from ...engine import Result
13
+ from ...engine import Transaction
14
+ from ...future import Connection
15
+ from ...future import Engine
16
+ from ...sql import Executable
17
17
18
- def create_async_engine (* arg : Any , ** kw : Any ): ...
18
+ _TAsyncConnection = TypeVar ("_TAsyncConnection" , bound = AsyncConnection )
19
+ _TAsyncTransaction = TypeVar ("_TAsyncTransaction" , bound = AsyncTransaction )
20
+
21
+ def create_async_engine (* arg : Any , ** kw : Any ) -> AsyncEngine : ...
19
22
20
23
class AsyncConnectable : ...
21
24
22
25
class AsyncConnection (ProxyComparable , StartableContext , AsyncConnectable ):
23
- engine : Any = ...
24
- sync_engine : Any = ...
25
- sync_connection : Any = ...
26
+ # copied from future.Connection via create_proxy_methods
27
+ @property
28
+ def closed (self ) -> bool : ...
29
+ @property
30
+ def invalidated (self ) -> bool : ...
31
+ dialect : Any
32
+ @property
33
+ def default_isolation_level (self ) -> Any : ...
34
+ # end copied
35
+
36
+ engine : AsyncEngine = ...
37
+ sync_engine : Engine = ...
38
+ sync_connection : Optional [Connection ] = ...
26
39
def __init__ (
27
40
self ,
28
41
async_engine : AsyncEngine ,
29
42
sync_connection : Optional [Connection ] = ...,
30
43
) -> None : ...
31
- async def start (self ) : ...
44
+ async def start (self : _TAsyncConnection ) -> _TAsyncConnection : ...
32
45
@property
33
- def connection (self ) -> None : ...
34
- async def get_raw_connection (self ): ...
46
+ def connection (self ) -> NoReturn : ...
47
+ async def get_raw_connection (self ) -> Any : ...
35
48
@property
36
- def info (self ): ...
49
+ def info (self ) -> Mapping [ Any , Any ] : ...
37
50
def begin (self ) -> AsyncTransaction : ...
38
51
def begin_nested (self ) -> AsyncTransaction : ...
39
- async def invalidate (self , exception : Optional [Any ] = ...): ...
40
- async def get_isolation_level (self ): ...
41
- async def set_isolation_level (self ): ...
42
- def in_transaction (self ): ...
43
- def in_nested_transaction (self ): ...
44
- def get_transaction (self ): ...
45
- def get_nested_transaction (self ): ...
46
- async def execution_options (self , ** opt : Any ): ...
52
+ async def invalidate (self , exception : Optional [Any ] = ...) -> None : ...
53
+ async def get_isolation_level (self ) -> Any : ...
54
+ async def set_isolation_level (self ) -> Any : ...
55
+ def in_transaction (self ) -> bool : ...
56
+ def in_nested_transaction (self ) -> bool : ...
57
+ def get_transaction (self ) -> Optional [AsyncTransaction ]: ...
58
+ def get_nested_transaction (self ) -> Optional [AsyncTransaction ]: ...
59
+ async def execution_options (
60
+ self : _TAsyncConnection , ** opt : Any
61
+ ) -> _TAsyncConnection : ...
47
62
async def commit (self ) -> None : ...
48
63
async def rollback (self ) -> None : ...
49
64
async def close (self ) -> None : ...
50
65
async def exec_driver_sql (
51
66
self ,
52
- statement : Executable ,
53
- parameters : Optional [Mapping ] = ...,
54
- execution_options : Mapping = ...,
67
+ statement : str ,
68
+ parameters : Optional [Mapping [ Any , Any ] ] = ...,
69
+ execution_options : Mapping [ Any , Any ] = ...,
55
70
) -> Result : ...
56
71
async def stream (
57
72
self ,
58
73
statement : Executable ,
59
- parameters : Optional [Mapping ] = ...,
60
- execution_options : Mapping = ...,
74
+ parameters : Optional [Mapping [ Any , Any ] ] = ...,
75
+ execution_options : Mapping [ Any , Any ] = ...,
61
76
) -> AsyncResult : ...
62
77
async def execute (
63
78
self ,
64
79
statement : Executable ,
65
- parameters : Optional [Mapping ] = ...,
66
- execution_options : Mapping = ...,
80
+ parameters : Optional [Mapping [ Any , Any ] ] = ...,
81
+ execution_options : Mapping [ Any , Any ] = ...,
67
82
) -> Result : ...
68
83
async def scalar (
69
84
self ,
70
85
statement : Executable ,
71
- parameters : Optional [Mapping ] = ...,
72
- execution_options : Mapping = ...,
86
+ parameters : Optional [Mapping [Any , Any ]] = ...,
87
+ execution_options : Mapping [Any , Any ] = ...,
88
+ ) -> Any : ...
89
+ async def run_sync (
90
+ self , fn : Callable [..., Any ], * arg : Any , ** kw : Any
73
91
) -> Any : ...
74
- async def run_sync (self , fn : Callable , * arg : Any , ** kw : Any ) -> Any : ...
75
- def __await__ (self ): ...
92
+ def __await__ (
93
+ self : _TAsyncConnection ,
94
+ ) -> Generator [Any , None , _TAsyncConnection ]: ...
76
95
async def __aexit__ (
77
96
self , type_ : Any , value : Any , traceback : Any
78
97
) -> None : ...
79
98
80
99
class AsyncEngine (ProxyComparable , AsyncConnectable ):
100
+ # copied from future.Engine by create_proxy_methods
101
+ def clear_compiled_cache (self ) -> None : ...
102
+ def update_execution_options (self , ** opt : Any ) -> None : ...
103
+ def get_execution_options (self ) -> Mapping [Any , Any ]: ...
104
+ # end copied
81
105
class _trans_ctx (StartableContext ):
82
- conn : Any = ...
83
- def __init__ (self , conn : Any ) -> None : ...
106
+ conn : AsyncConnection = ...
107
+ def __init__ (self , conn : AsyncConnection ) -> None : ...
84
108
transaction : Any = ...
85
- async def start (self ): ...
109
+ async def start (self ) -> AsyncConnection : ... # type: ignore[override]
110
+ def __await__ (self ) -> Generator [Any , None , AsyncConnection ]: ... # type: ignore[override]
86
111
async def __aexit__ (
87
112
self , type_ : Any , value : Any , traceback : Any
88
113
) -> None : ...
89
- sync_engine : Any = ...
114
+ sync_engine : Engine = ...
90
115
def __init__ (self , sync_engine : Engine ) -> None : ...
91
- def begin (self ): ...
116
+ def begin (self ) -> _trans_ctx : ...
92
117
def connect (self ) -> AsyncConnection : ...
93
118
async def raw_connection (self ) -> Any : ...
94
- def execution_options (self , ** opt : Any ): ...
95
- async def dispose (self ): ...
119
+ def execution_options (self , ** opt : Any ) -> AsyncEngine : ...
120
+ async def dispose (self ) -> None : ...
96
121
97
122
class AsyncTransaction (ProxyComparable , StartableContext ):
98
- connection : Any = ...
99
- sync_transaction : Any = ...
100
- nested : Any = ...
123
+ connection : AsyncConnection = ...
124
+ sync_transaction : Optional [ Transaction ] = ...
125
+ nested : bool = ...
101
126
def __init__ (
102
127
self , connection : AsyncConnection , nested : bool = ...
103
128
) -> None : ...
@@ -108,7 +133,7 @@ class AsyncTransaction(ProxyComparable, StartableContext):
108
133
async def close (self ) -> None : ...
109
134
async def rollback (self ) -> None : ...
110
135
async def commit (self ) -> None : ...
111
- async def start (self ) : ...
136
+ async def start (self : _TAsyncTransaction ) -> _TAsyncTransaction : ...
112
137
async def __aexit__ (
113
138
self , type_ : Any , value : Any , traceback : Any
114
139
) -> None : ...
0 commit comments