summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2022-11-21 21:24:11 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2022-11-21 21:24:11 +0000
commit4f0da8f07a9b7e326a1f1c88a4361cd852f1f874 (patch)
tree60660694167a57cd52433dd0deda12416a9a2714 /lib
parent5ff55f70780788938ab81b7f24a5ce75c3cd45b9 (diff)
parente43e240a0088ac429eb551c7ea1c537c266b4853 (diff)
downloadsqlalchemy-4f0da8f07a9b7e326a1f1c88a4361cd852f1f874.tar.gz
Merge "Fix inferred type of async_sessionmaker" into main
Diffstat (limited to 'lib')
-rw-r--r--lib/sqlalchemy/ext/asyncio/session.py27
-rw-r--r--lib/sqlalchemy/orm/session.py27
2 files changed, 54 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/asyncio/session.py b/lib/sqlalchemy/ext/asyncio/session.py
index 1956ea588..a74e87769 100644
--- a/lib/sqlalchemy/ext/asyncio/session.py
+++ b/lib/sqlalchemy/ext/asyncio/session.py
@@ -124,6 +124,7 @@ class AsyncSession(ReversibleProxy[Session]):
def __init__(
self,
bind: Optional[_AsyncSessionBind] = None,
+ *,
binds: Optional[Dict[_SessionBindKey, _AsyncSessionBind]] = None,
sync_session_class: Optional[Type[Session]] = None,
**kw: Any,
@@ -1436,9 +1437,35 @@ class async_sessionmaker(Generic[_AS]):
class_: Type[_AS]
+ @overload
+ def __init__(
+ self,
+ bind: Optional[_AsyncSessionBind] = ...,
+ *,
+ class_: Type[_AS],
+ autoflush: bool = ...,
+ expire_on_commit: bool = ...,
+ info: Optional[_InfoType] = ...,
+ **kw: Any,
+ ):
+ ...
+
+ @overload
+ def __init__(
+ self: "async_sessionmaker[AsyncSession]",
+ bind: Optional[_AsyncSessionBind] = ...,
+ *,
+ autoflush: bool = ...,
+ expire_on_commit: bool = ...,
+ info: Optional[_InfoType] = ...,
+ **kw: Any,
+ ):
+ ...
+
def __init__(
self,
bind: Optional[_AsyncSessionBind] = None,
+ *,
class_: Type[_AS] = AsyncSession, # type: ignore
autoflush: bool = True,
expire_on_commit: bool = True,
diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py
index 849d37ab2..15cd58792 100644
--- a/lib/sqlalchemy/orm/session.py
+++ b/lib/sqlalchemy/orm/session.py
@@ -1362,6 +1362,7 @@ class Session(_SessionClassMethods, EventTarget):
def __init__(
self,
bind: Optional[_SessionBind] = None,
+ *,
autoflush: bool = True,
future: Literal[True] = True,
expire_on_commit: bool = True,
@@ -4621,9 +4622,35 @@ class sessionmaker(_SessionClassMethods, Generic[_S]):
class_: Type[_S]
+ @overload
+ def __init__(
+ self,
+ bind: Optional[_SessionBind] = ...,
+ *,
+ class_: Type[_S],
+ autoflush: bool = ...,
+ expire_on_commit: bool = ...,
+ info: Optional[_InfoType] = ...,
+ **kw: Any,
+ ):
+ ...
+
+ @overload
+ def __init__(
+ self: "sessionmaker[Session]",
+ bind: Optional[_SessionBind] = ...,
+ *,
+ autoflush: bool = ...,
+ expire_on_commit: bool = ...,
+ info: Optional[_InfoType] = ...,
+ **kw: Any,
+ ):
+ ...
+
def __init__(
self,
bind: Optional[_SessionBind] = None,
+ *,
class_: Type[_S] = Session, # type: ignore
autoflush: bool = True,
expire_on_commit: bool = True,