diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2022-07-18 15:42:44 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@ci3.zzzcomputing.com> | 2022-07-18 15:42:44 +0000 |
commit | cf465130337873bde8afb5cae11cc4f60c0e7256 (patch) | |
tree | 8056e5d2e3e3ce10014c4eb82d97f7aa66c76d3d /lib/sqlalchemy/ext/asyncio/engine.py | |
parent | 85a88df13ab8d217331cf98392544a888b4d7df3 (diff) | |
parent | 10204576215fad27640739c295b9208a0bb3c6ce (diff) | |
download | sqlalchemy-cf465130337873bde8afb5cae11cc4f60c0e7256.tar.gz |
Merge "add contextmanager typing, open run_sync typing" into main
Diffstat (limited to 'lib/sqlalchemy/ext/asyncio/engine.py')
-rw-r--r-- | lib/sqlalchemy/ext/asyncio/engine.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/sqlalchemy/ext/asyncio/engine.py b/lib/sqlalchemy/ext/asyncio/engine.py index 97d69fcbd..2418dab88 100644 --- a/lib/sqlalchemy/ext/asyncio/engine.py +++ b/lib/sqlalchemy/ext/asyncio/engine.py @@ -7,6 +7,7 @@ from __future__ import annotations from typing import Any +from typing import Callable from typing import Dict from typing import Generator from typing import NoReturn @@ -33,7 +34,6 @@ from ...engine import Engine from ...engine.base import NestedTransaction from ...engine.base import Transaction from ...util.concurrency import greenlet_spawn -from ...util.typing import Protocol if TYPE_CHECKING: from ...engine.cursor import CursorResult @@ -55,11 +55,6 @@ if TYPE_CHECKING: _T = TypeVar("_T", bound=Any) -class _SyncConnectionCallable(Protocol): - def __call__(self, connection: Connection, *arg: Any, **kw: Any) -> Any: - ... - - def create_async_engine(url: Union[str, URL], **kw: Any) -> AsyncEngine: """Create a new async engine instance. @@ -667,7 +662,7 @@ class AsyncConnection( return result.scalars() async def run_sync( - self, fn: _SyncConnectionCallable, *arg: Any, **kw: Any + self, fn: Callable[..., Any], *arg: Any, **kw: Any ) -> Any: """Invoke the given sync callable passing self as the first argument. @@ -845,6 +840,11 @@ class AsyncEngine(ProxyComparable[Engine], AsyncConnectable): def __init__(self, conn: AsyncConnection): self.conn = conn + if TYPE_CHECKING: + + async def __aenter__(self) -> AsyncConnection: + ... + async def start(self, is_ctxmanager: bool = False) -> AsyncConnection: await self.conn.start(is_ctxmanager=is_ctxmanager) self.transaction = self.conn.begin() |