MOTOR-1470 - Add Deprecation Warning to Motor (#340)

This commit is contained in:
Noah Stapp 2025-08-04 14:35:30 -04:00 committed by GitHub
parent 5fc7c41fb5
commit 5bcdd4ad6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View File

@ -171,6 +171,21 @@ class AgnosticClient(AgnosticBaseProperties):
delegate = self.__delegate_class__(*args, **kwargs)
super().__init__(delegate)
warnings.warn(
DeprecationWarning(
"""Motor is deprecated as of May 14th, 2025,
in favor of the GA release of the PyMongo Async API.
No new features will be added to Motor,
and only bug fixes will be provided until it reaches end of life on May 14th, 2026.
After that, only critical bug fixes will be made until final support ends on May 14th, 2027.
We strongly recommend migrating to the PyMongo Async API while Motor is still supported.
For help transitioning, see the Migrate to PyMongo Async guide here:
https://www.mongodb.com/docs/languages/python/pymongo-driver/current/reference/migration/
"""
),
stacklevel=2,
)
@property
def io_loop(self):
if self._io_loop is None:

View File

@ -103,6 +103,8 @@ filterwarnings = [
# TODO: Remove both of these in https://jira.mongodb.org/browse/PYTHON-4731
"ignore:Unclosed AsyncMongoClient*",
"ignore:Unclosed MongoClient*",
# Deprecation warning now that Motor is officially deprecated
"ignore:Motor is deprecated*",
]
[tool.ruff]