11from typing import Any
22from typing import Callable
3+ from typing import Generator
34from typing import Mapping
5+ from typing import NoReturn
46from typing import Optional
7+ from typing import TypeVar
58
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
1717
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 : ...
1922
2023class AsyncConnectable : ...
2124
2225class 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 ] = ...
2639 def __init__ (
2740 self ,
2841 async_engine : AsyncEngine ,
2942 sync_connection : Optional [Connection ] = ...,
3043 ) -> None : ...
31- async def start (self ) : ...
44+ async def start (self : _TAsyncConnection ) -> _TAsyncConnection : ...
3245 @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 : ...
3548 @property
36- def info (self ): ...
49+ def info (self ) -> Mapping [ Any , Any ] : ...
3750 def begin (self ) -> AsyncTransaction : ...
3851 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 : ...
4762 async def commit (self ) -> None : ...
4863 async def rollback (self ) -> None : ...
4964 async def close (self ) -> None : ...
5065 async def exec_driver_sql (
5166 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 ] = ...,
5570 ) -> Result : ...
5671 async def stream (
5772 self ,
5873 statement : Executable ,
59- parameters : Optional [Mapping ] = ...,
60- execution_options : Mapping = ...,
74+ parameters : Optional [Mapping [ Any , Any ] ] = ...,
75+ execution_options : Mapping [ Any , Any ] = ...,
6176 ) -> AsyncResult : ...
6277 async def execute (
6378 self ,
6479 statement : Executable ,
65- parameters : Optional [Mapping ] = ...,
66- execution_options : Mapping = ...,
80+ parameters : Optional [Mapping [ Any , Any ] ] = ...,
81+ execution_options : Mapping [ Any , Any ] = ...,
6782 ) -> Result : ...
6883 async def scalar (
6984 self ,
7085 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
7391 ) -> 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 ]: ...
7695 async def __aexit__ (
7796 self , type_ : Any , value : Any , traceback : Any
7897 ) -> None : ...
7998
8099class 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
81105 class _trans_ctx (StartableContext ):
82- conn : Any = ...
83- def __init__ (self , conn : Any ) -> None : ...
106+ conn : AsyncConnection = ...
107+ def __init__ (self , conn : AsyncConnection ) -> None : ...
84108 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]
86111 async def __aexit__ (
87112 self , type_ : Any , value : Any , traceback : Any
88113 ) -> None : ...
89- sync_engine : Any = ...
114+ sync_engine : Engine = ...
90115 def __init__ (self , sync_engine : Engine ) -> None : ...
91- def begin (self ): ...
116+ def begin (self ) -> _trans_ctx : ...
92117 def connect (self ) -> AsyncConnection : ...
93118 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 : ...
96121
97122class AsyncTransaction (ProxyComparable , StartableContext ):
98- connection : Any = ...
99- sync_transaction : Any = ...
100- nested : Any = ...
123+ connection : AsyncConnection = ...
124+ sync_transaction : Optional [ Transaction ] = ...
125+ nested : bool = ...
101126 def __init__ (
102127 self , connection : AsyncConnection , nested : bool = ...
103128 ) -> None : ...
@@ -108,7 +133,7 @@ class AsyncTransaction(ProxyComparable, StartableContext):
108133 async def close (self ) -> None : ...
109134 async def rollback (self ) -> None : ...
110135 async def commit (self ) -> None : ...
111- async def start (self ) : ...
136+ async def start (self : _TAsyncTransaction ) -> _TAsyncTransaction : ...
112137 async def __aexit__ (
113138 self , type_ : Any , value : Any , traceback : Any
114139 ) -> None : ...
0 commit comments