From 2f75a4030c6fbf076d5a50d2b0e6a492a5bcaa9c Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 26 Apr 2022 07:54:00 -0500 Subject: [PATCH] MOTOR-946 Deprecated APIs will not be Removed in Motor 3.0 (#168) --- doc/developer-guide.rst | 2 +- motor/core.py | 12 ++++++------ motor/frameworks/asyncio/__init__.py | 2 +- motor/frameworks/tornado/__init__.py | 2 +- motor/motor_gridfs.py | 1 + 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/doc/developer-guide.rst b/doc/developer-guide.rst index 230f6784..438479f2 100644 --- a/doc/developer-guide.rst +++ b/doc/developer-guide.rst @@ -45,7 +45,7 @@ See the ``frameworks/tornado`` and ``frameworks/asyncio`` modules. list above are not used internally in Motor. Instead of being removed from the codebase, they have been left in a deprecated state to avoid breaking any libraries built on top of Motor. These deprecated functions - will be removed in Motor 3.0. + may be removed in a future major release. A framework-specific class, like ``MotorClient`` for Tornado or ``AsyncIOMotorClient`` for asyncio, is created by the diff --git a/motor/core.py b/motor/core.py index 1249af87..e32889f5 100644 --- a/motor/core.py +++ b/motor/core.py @@ -1324,8 +1324,8 @@ def fetch_next(self): .. _`gen.coroutine`: http://tornadoweb.org/en/stable/gen.html """ warnings.warn( - "The fetch_next property is deprecated and will be " - "removed in Motor 3.0. Use `async for` to iterate " + "The fetch_next property is deprecated and may be " + "removed in a future major release. Use `async for` to iterate " "over Cursor objects instead.", DeprecationWarning, stacklevel=2, @@ -1348,16 +1348,16 @@ def next_object(self): """**DEPRECATED** - Get a document from the most recently fetched batch, or ``None``. See :attr:`fetch_next`. - The :meth:`next_object` method is deprecated and will be removed - in Motor 3.0. Use `async for` to elegantly iterate over + The :meth:`next_object` method is deprecated and may be removed + in a future major release. Use `async for` to elegantly iterate over :class:`MotorCursor` objects instead. .. versionchanged:: 2.2 Deprecated. """ warnings.warn( - "The next_object method is deprecated and will be " - "removed in Motor 3.0. Use Use `async for` to iterate " + "The next_object method is deprecated and may be " + "removed in a future major release. Use `async for` to iterate " "over Cursor objects instead.", DeprecationWarning, stacklevel=2, diff --git a/motor/frameworks/asyncio/__init__.py b/motor/frameworks/asyncio/__init__.py index ea5c72ea..1856cc23 100644 --- a/motor/frameworks/asyncio/__init__.py +++ b/motor/frameworks/asyncio/__init__.py @@ -147,7 +147,7 @@ async def _wrapper(self, *args, **kwargs): def yieldable(future): warnings.warn( - "The yieldable function is deprecated and will be removed in Motor 3.0", + "The yieldable function is deprecated and may be removed in a future major release", DeprecationWarning, stacklevel=2, ) diff --git a/motor/frameworks/tornado/__init__.py b/motor/frameworks/tornado/__init__.py index 3d34a675..97f96de2 100644 --- a/motor/frameworks/tornado/__init__.py +++ b/motor/frameworks/tornado/__init__.py @@ -129,7 +129,7 @@ async def _wrapper(self, *args, **kwargs): def yieldable(future): warnings.warn( - "The yieldable function is deprecated and will be removed in Motor 3.0", + "The yieldable function is deprecated and may be removed in a future major release.", DeprecationWarning, stacklevel=2, ) diff --git a/motor/motor_gridfs.py b/motor/motor_gridfs.py index c474a03d..32d10fe2 100644 --- a/motor/motor_gridfs.py +++ b/motor/motor_gridfs.py @@ -43,6 +43,7 @@ class AgnosticGridOutCursor(AgnosticCursor): def next_object(self): """**DEPRECATED** - Get next GridOut object from cursor.""" + # Note: the super() call will raise a warning for the deprecation. grid_out = super().next_object() if grid_out: grid_out_class = create_class_with_framework(