Skip to content

Commit

Permalink
📌 Make pymongo always required, as Motor deeply depends on it (e.g. f…
Browse files Browse the repository at this point in the history
…or bulk writes)
  • Loading branch information
tiangolo committed Jun 22, 2022
1 parent ea1ea28 commit f7460a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
24 changes: 5 additions & 19 deletions odmantic/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
<!---
#noqa: DAR401 RuntimeError
-->
"""
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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit f7460a6

Please sign in to comment.