From f7460a6db7cebfcebb43bf8cb06504df5e31471d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Wed, 22 Jun 2022 15:27:07 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=8C=20Make=20pymongo=20always=20requir?= =?UTF-8?q?ed,=20as=20Motor=20deeply=20depends=20on=20it=20(e.g.=20for=20b?= =?UTF-8?q?ulk=20writes)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- odmantic/engine.py | 24 +++++------------------- pyproject.toml | 2 +- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/odmantic/engine.py b/odmantic/engine.py index 809a0b71..0f8e87fc 100644 --- a/odmantic/engine.py +++ b/odmantic/engine.py @@ -21,22 +21,17 @@ ) from pydantic.utils import lenient_issubclass +from pymongo import MongoClient +from pymongo.client_session import ClientSession +from pymongo.collection import Collection +from pymongo.command_cursor import CommandCursor +from pymongo.database import Database from odmantic.exceptions import DocumentNotFoundError from odmantic.field import FieldProxy, ODMReference from odmantic.model import Model from odmantic.query import QueryExpression, SortExpression, and_ -try: - import pymongo - from pymongo import MongoClient - from pymongo.client_session import ClientSession - from pymongo.collection import Collection - from pymongo.command_cursor import CommandCursor - from pymongo.database import Database -except ImportError: # pragma: no cover - pymongo = None - try: import motor from motor.motor_asyncio import ( @@ -546,16 +541,7 @@ def __init__( client: instance of a PyMongo client. If None, a default one will be created database: name of the database to use - - """ - if not pymongo: - raise RuntimeError( - "pymongo is required to use SyncEngine, install it with:\n\n" - + 'pip install "odmantic[pymongo]"' - ) if client is None: client = MongoClient() super().__init__(client=client, database=database) diff --git a/pyproject.toml b/pyproject.toml index 63c6ccaa..49deceb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,6 +38,7 @@ dependencies = [ "pydantic >=1.6.2,!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<1.10.0", "importlib-metadata >=1,<5; python_version<'3.8'", "typing-extensions >= 3.7.4.3; python_version<'3.8'", + "pymongo >=3.11.0,<5.0.0", ] [project.optional-dependencies] fastapi = ["fastapi >=0.61.1,<0.69.0"] @@ -70,7 +71,6 @@ doc = [ ] dev = ["ipython ~= 7.16.1"] motor = ["motor >=2.1.0,<3.1.0"] -pymongo = ["pymongo >=3.11.0,<5.0.0"] [project.urls] Documentation = "https://art049.github.io/odmantic"