]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixes: #11083 (#11095)
authorDaniel Robert <daniel.robert@acm.org>
Mon, 11 Mar 2024 21:34:20 +0000 (14:34 -0700)
committerGitHub <noreply@github.com>
Mon, 11 Mar 2024 21:34:20 +0000 (22:34 +0100)
lib/sqlalchemy/engine/util.py
test/typing/plain_files/orm/session.py

index e047b94b79223d53b7d9f7ae978c37871355f3ab..34c615c841d6adbf179fdf2ffc0916ce8c96a2b4 100644 (file)
@@ -17,6 +17,7 @@ from typing import TypeVar
 from .. import exc
 from .. import util
 from ..util._has_cy import HAS_CYEXTENSION
+from ..util.typing import Self
 
 if typing.TYPE_CHECKING or not HAS_CYEXTENSION:
     from ._py_util import _distill_params_20 as _distill_params_20
@@ -113,7 +114,7 @@ class TransactionalContext:
                     "before emitting further commands."
                 )
 
-    def __enter__(self) -> TransactionalContext:
+    def __enter__(self) -> Self:
         subject = self._get_subject()
 
         # none for outer transaction, may be non-None for nested
index 12a261a84f7cb7afdffb23dacbfe926ce1134014..39b41dfbb7744bb8ed76c3d82a9d93b9f883cb4b 100644 (file)
@@ -97,6 +97,12 @@ with Session(e) as sess:
         User.id
     ).offset(User.id)
 
+    # test #11083
+
+    with sess.begin() as tx:
+        # EXPECTED_TYPE: SessionTransaction
+        reveal_type(tx)
+
 # more result tests in typed_results.py