Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 27 additions & 56 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,23 @@ env:
MONGODB_7_0: "7.0.19"
MONGODB_8_0: "8.0.9"

PYMONGO_3_12: "3.12.3"
PYMONGO_3_13: "3.13.0"
PYMONGO_4_0: "4.0.2"
PYMONGO_4_3: "4.3.3"
PYMONGO_4_4: "4.4.1"
PYMONGO_4_6: "4.6.2"
PYMONGO_4_7: "4.7.3"
PYMONGO_4_8: "4.8.0"
PYMONGO_4_9: "4.9.2"
PYMONGO_4_10: "4.10.1"
PYMONGO_4_11: "4.11.2"
PYMONGO_4_14: "4.14.1"
PYMONGO_4_15: "4.15.5"
PYMONGO_4_16: "4.16.0"
PYMONGO_4_17: "4.17.0"

MAIN_PYTHON_VERSION: "3.9"
MAIN_PYTHON_VERSION: "3.14"

jobs:
linting:
# Run pre-commit (https://pre-commit.com/)
# which runs pre-configured linter & autoformatter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
check-latest: true
Expand All @@ -54,53 +49,29 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.9", "pypy3.10"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "pypy3.10"]
MONGODB: [$MONGODB_4_4]
PYMONGO: [$PYMONGO_3_12]
PYMONGO: [$PYMONGO_4_8]
include:
- python-version: "3.9"
MONGODB: $MONGODB_4_4
PYMONGO: $PYMONGO_3_13
- python-version: "3.10"
MONGODB: $MONGODB_4_4
PYMONGO: $PYMONGO_4_0
- python-version: "3.11"
MONGODB: $MONGODB_5_0
PYMONGO: $PYMONGO_4_3
- python-version: "3.11"
MONGODB: $MONGODB_6_0
PYMONGO: $PYMONGO_4_4
- python-version: "3.11"
MONGODB: $MONGODB_7_0
PYMONGO: $PYMONGO_4_6
- python-version: "3.11"
MONGODB: $MONGODB_7_0
PYMONGO: $PYMONGO_4_7
- python-version: "3.11"
MONGODB: $MONGODB_7_0
PYMONGO: $PYMONGO_4_8
- python-version: "3.11"
MONGODB: $MONGODB_7_0
PYMONGO: $PYMONGO_4_9
- python-version: "3.12"
MONGODB: $MONGODB_7_0
PYMONGO: $PYMONGO_4_9
PYMONGO: $PYMONGO_4_10
- python-version: "3.12"
MONGODB: $MONGODB_8_0
PYMONGO: $PYMONGO_4_9
MONGODB: $MONGODB_6_0
PYMONGO: $PYMONGO_4_14
- python-version: "3.13"
MONGODB: $MONGODB_8_0
PYMONGO: $PYMONGO_4_9
MONGODB: $MONGODB_7_0
PYMONGO: $PYMONGO_4_15
- python-version: "3.13"
MONGODB: $MONGODB_8_0
PYMONGO: $PYMONGO_4_10
- python-version: "3.13"
PYMONGO: $PYMONGO_4_16
- python-version: "3.14"
MONGODB: $MONGODB_8_0
PYMONGO: $PYMONGO_4_11
PYMONGO: $PYMONGO_4_17
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
check-latest: true
Expand All @@ -127,9 +98,9 @@ jobs:
# builds are visible at https://readthedocs.org/projects/mongoengine-odm/builds/
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
check-latest: true
Expand All @@ -146,32 +117,32 @@ jobs:
runs-on: ubuntu-latest
needs: [linting, test, build_doc_dryrun]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
check-latest: true
- name: build dummy wheel for test-pypi
run: |
pip install wheel
pip install setuptools wheel
python setup.py sdist bdist_wheel

build-n-publish:
runs-on: ubuntu-latest
needs: [linting, test, build_doc_dryrun, build-dryrun]
if: github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Set up Python ${{ env.MAIN_PYTHON_VERSION }}
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}
check-latest: true
# todo separate build from publish
# https://stackoverflow.com/questions/59349905/which-properties-does-github-event-in-a-github-workflow-have
- name: build dummy wheel for test-pypi
run: |
pip install wheel
pip install setuptools wheel
python setup.py sdist bdist_wheel
- name: publish pypi
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/install_mongo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ if [ ! -d "$mongosh_dir" ]; then
exit 1
fi

# creating a ".path" file to make sure start_mongo is referring to the same binaries
# that this installation is referring to
echo >&2 "Creating mongo.path"
echo "export PATH='${mongodb_dir}/bin:${mongosh_dir}/bin:'"'$PATH' \
| tee >&2 mongo.path
Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: check-merge-conflict
- id: debug-statements
- id: trailing-whitespace
- id: end-of-file-fixer
- repo: https://github.com/ambv/black
rev: 25.1.0
rev: 26.5.1
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 7.2.0
rev: 7.3.0
hooks:
- id: flake8
additional_dependencies:
- importlib_metadata<5
- repo: https://github.com/asottile/pyupgrade
rev: v3.19.1
rev: v3.21.2
hooks:
- id: pyupgrade
args: [--py36-plus]
args: [--py310-plus]
- repo: https://github.com/pycqa/isort
rev: 6.0.1
rev: 9.0.0a3
hooks:
- id: isort
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ services:
image: mongoengine:latest
ports:
- 27017:27017
ulimits:
nofile:
soft: 64000
hard: 64000
7 changes: 2 additions & 5 deletions mongoengine/base/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,11 @@ def get(name):
if len(possible_match) == 1:
doc = _document_registry.get(possible_match.pop(), None)
if not doc:
raise NotRegistered(
"""
raise NotRegistered("""
`%s` has not been registered in the document registry.
Importing the document class automatically registers it, has it
been imported?
""".strip()
% name
)
""".strip() % name)
return doc

@staticmethod
Expand Down
9 changes: 6 additions & 3 deletions mongoengine/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,12 @@ def _get_connection_settings(
if uri_dict.get(param):
conn_settings[param] = uri_dict[param]

uri_options = uri_dict[
"options"
] # uri_options is a _CaseInsensitiveDictionary
# PyMongo < 4.14 returned a case-insensitive options mapping, but
# PyMongo >= 4.14 returns a plain dict with canonical option names.
# Normalize keys so lookups stay compatible across supported versions.
uri_options = {
key.lower(): value for key, value in uri_dict["options"].items()
}
if "replicaset" in uri_options:
conn_settings["replicaSet"] = uri_options["replicaset"]
if "authsource" in uri_options:
Expand Down
4 changes: 1 addition & 3 deletions mongoengine/queryset/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1866,9 +1866,7 @@ def _item_frequencies_map_reduce(self, field, normalize=False):
emit(null, 1);
}}
}}
""".format(
field=field
)
""".format(field=field)
reduce_func = """
function(key, values) {
var total = 0;
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ def get_version(version_tuple):
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Database",
Expand Down Expand Up @@ -68,7 +68,7 @@ def get_version(version_tuple):
long_description=LONG_DESCRIPTION,
platforms=["any"],
classifiers=CLASSIFIERS,
python_requires=">=3.7",
python_requires=">=3.10",
install_requires=install_require,
extras_require={
"test": tests_require,
Expand Down
8 changes: 2 additions & 6 deletions tests/document/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -3042,14 +3042,10 @@ def __str__(self):
assert susan_karl_books_qs.count() == 1

# $Where
custom_qs = Book.objects.filter(
__raw__={
"$where": """
custom_qs = Book.objects.filter(__raw__={"$where": """
function(){
return this.name == '1' ||
this.name == '2';}"""
}
)
this.name == '2';}"""})
assert [str(b) for b in custom_qs] == ["1", "2"]

# count only will work with this raw query before pymongo 4.x, but
Expand Down
17 changes: 6 additions & 11 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
[tox]
envlist =
pypy3-{mg3123,mg3130,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg4101,mg4112}
py{39,310,311,312,313}-{mg3123,mg3130,mg402,mg433,mg441,mg462,mg473,mg480,mg492,mg4101,mg4112}
pypy3-{mg480,mg4101,mg4141,mg4155,mg4160,mg4170}
py{310,311,312,313,314}-{mg480,mg4101,mg4141,mg4155,mg4160,mg4170}
skipsdist = True

[testenv]
commands =
pytest tests/ {posargs}
deps =
-rrequirements-dev.txt
mg3123: pymongo>=3.12,<3.13
mg3130: pymongo>=3.13,<3.14
mg402: pymongo>=4.0,<4.1
mg433: pymongo>=4.3,<4.4
mg441: pymongo>=4.4,<4.5
mg462: pymongo>=4.6,<4.7
mg473: pymongo>=4.7,<4.8
mg480: pymongo>=4.8,<4.9
mg492: pymongo>=4.9,<4.10
mg4101: pymongo>=4.10,<4.11
mg4112: pymongo>=4.11,<4.12
mg4141: pymongo>=4.14,<4.15
mg4155: pymongo>=4.15,<4.16
mg4160: pymongo>=4.16,<4.17
mg4170: pymongo>=4.17,<4.18
setenv =
PYTHON_EGG_CACHE = {envdir}/python-eggs