From 5bcdd4ad6aedeaeb4c6831e024741315a7369630 Mon Sep 17 00:00:00 2001 From: Noah Stapp Date: Mon, 4 Aug 2025 14:35:30 -0400 Subject: [PATCH] MOTOR-1470 - Add Deprecation Warning to Motor (#340) --- motor/core.py | 15 +++++++++++++++ pyproject.toml | 2 ++ 2 files changed, 17 insertions(+) diff --git a/motor/core.py b/motor/core.py index f1f3ea05..cc3c500a 100644 --- a/motor/core.py +++ b/motor/core.py @@ -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: diff --git a/pyproject.toml b/pyproject.toml index f856bdf7..cf7aea21 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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]