]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix: add deprecated warning
authorBryan不可思议 <programripper@foxmail.com>
Fri, 6 Oct 2023 08:24:16 +0000 (08:24 +0000)
committerGitHub <noreply@github.com>
Fri, 6 Oct 2023 08:24:16 +0000 (08:24 +0000)
lib/sqlalchemy/ext/asyncio/session.py
test/ext/asyncio/test_session_py3k.py

index 429ff6e869a5ddf4b831e159f9d8b53bd5723877..75dd43281d8d780321073512234bc11ddca3b9e7 100644 (file)
@@ -1058,12 +1058,14 @@ class AsyncSession(ReversibleProxy[Session]):
         await greenlet_spawn(self.sync_session.invalidate)
 
     @classmethod
+    @util.deprecated(
+        "2.0",
+        "The :meth:`.AsyncSession.close_all` method is deprecated and will be "
+        "removed in a future release.  Please refer to "
+        ":func:`.session.close_all_sessions`.",
+    )
     async def close_all(cls) -> None:
-        """Close all :class:`_asyncio.AsyncSession` sessions.
-
-        .. deprecated:: 2.0 The :meth:`.AsyncSession.close_all` method is deprecated and will be removed in a future release.  Please refer to :func:`.session.close_all_sessions`.
-
-        """  # noqa: E501
+        """Close all :class:`_asyncio.AsyncSession` sessions."""
         await greenlet_spawn(close_all_sessions)
 
     async def __aenter__(self: _AS) -> _AS:
index a3988ea52d8e969095703686d2d20abb95af9ccc..61759f8a93147ad06c276558f207e46f2c9c648a 100644 (file)
@@ -128,7 +128,11 @@ class AsyncSessionTest(AsyncFixture):
         u = User(name="u")
         async_session.add(u)
         await async_session.commit()
-        await AsyncSession.close_all()
+        with expect_deprecated(
+            r"The AsyncSession.close_all\(\) method is deprecated and will "
+            "be removed in a future release. "
+        ):
+            await AsyncSession.close_all()
         assert async_session.sync_session.identity_map.values() == []