diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-07-18 08:48:55 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-07-18 11:03:31 -0400 |
commit | 10204576215fad27640739c295b9208a0bb3c6ce (patch) | |
tree | 0aac3a09abd8dd6f41ff16b774cb398e7d457ec1 /lib/sqlalchemy/ext/asyncio/session.py | |
parent | f1dff43a825fe779d52e12d9a823ede0edef9bb0 (diff) | |
download | sqlalchemy-10204576215fad27640739c295b9208a0bb3c6ce.tar.gz |
add contextmanager typing, open run_sync typing
was missing AsyncConnection type for the async
context manager.
fixing that revealed that _SyncConnectionCallable
and _SyncSessionCallable protocols are infeasible because
the given callable can have a lot of different signatures
that are compatible.
Change-Id: I559aa3dd88a902d0e7681c52223bb4bc0890adc1
Diffstat (limited to 'lib/sqlalchemy/ext/asyncio/session.py')
-rw-r--r-- | lib/sqlalchemy/ext/asyncio/session.py | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py index be3414cef..ea587f8de 100644 --- a/lib/sqlalchemy/ext/asyncio/session.py +++ b/lib/sqlalchemy/ext/asyncio/session.py @@ -7,6 +7,7 @@ from __future__ import annotations from typing import Any +from typing import Callable from typing import Dict from typing import Generic from typing import Iterable @@ -33,7 +34,6 @@ from ...orm import Session from ...orm import SessionTransaction from ...orm import state as _instance_state from ...util.concurrency import greenlet_spawn -from ...util.typing import Protocol if TYPE_CHECKING: from .engine import AsyncConnection @@ -68,11 +68,6 @@ _AsyncSessionBind = Union["AsyncEngine", "AsyncConnection"] _T = TypeVar("_T", bound=Any) -class _SyncSessionCallable(Protocol): - def __call__(self, session: Session, *arg: Any, **kw: Any) -> Any: - ... - - _EXECUTE_OPTIONS = util.immutabledict({"prebuffer_rows": True}) _STREAM_OPTIONS = util.immutabledict({"stream_results": True}) @@ -234,7 +229,7 @@ class AsyncSession(ReversibleProxy[Session]): ) async def run_sync( - self, fn: _SyncSessionCallable, *arg: Any, **kw: Any + self, fn: Callable[..., Any], *arg: Any, **kw: Any ) -> Any: """Invoke the given sync callable passing sync self as the first argument. |