Skip to content

Commit 38ebb5a

Browse files
authored
Merge branch 'master' into feature/allow-setting-read-concern-queryset
2 parents 7cc964c + 9b73be2 commit 38ebb5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+687
-863
lines changed

.gitignore

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1-
.*
21
!.gitignore
32
*~
43
*.py[co]
54
.*.sw[po]
5+
.cache/
6+
.coverage
7+
.coveragerc
8+
.env
9+
.idea/
10+
.pytest_cache/
11+
.tox/
12+
.eggs/
613
*.egg
714
docs/.build
815
docs/_build
@@ -13,8 +20,6 @@ env/
1320
.settings
1421
.project
1522
.pydevproject
16-
tests/test_bugfix.py
1723
htmlcov/
1824
venv
1925
venv3
20-
scratchpad

.landscape.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,12 @@ pylint:
55

66
options:
77
additional-builtins:
8-
# add xrange and long as valid built-ins. In Python 3, xrange is
9-
# translated into range and long is translated into int via 2to3 (see
10-
# "use_2to3" in setup.py). This should be removed when we drop Python
11-
# 2 support (which probably won't happen any time soon).
12-
- xrange
8+
# add long as valid built-ins.
139
- long
1410

1511
pyflakes:
1612
disable:
17-
# undefined variables are already covered by pylint (and exclude
18-
# xrange & long)
13+
# undefined variables are already covered by pylint (and exclude long)
1914
- F821
2015

2116
ignore-paths:

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
fail_fast: false
2+
repos:
3+
- repo: https://github.com/ambv/black
4+
rev: 19.10b0
5+
hooks:
6+
- id: black
7+
- repo: https://gitlab.com/pycqa/flake8
8+
rev: 3.8.0a2
9+
hooks:
10+
- id: flake8
11+
additional_dependencies:
12+
- flake8-import-order

.travis.yml

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
# For full coverage, we'd have to test all supported Python, MongoDB, and
22
# PyMongo combinations. However, that would result in an overly long build
33
# with a very large number of jobs, hence we only test a subset of all the
4-
# combinations:
5-
# * MongoDB v3.4 & the latest PyMongo v3.x is currently the "main" setup,
6-
# tested against Python v2.7, v3.5, v3.6, v3.7, v3.8, PyPy and PyPy3.
7-
# * Besides that, we test the lowest actively supported Python/MongoDB/PyMongo
8-
# combination: MongoDB v3.4, PyMongo v3.4, Python v2.7.
9-
# * MongoDB v3.6 is tested against Python v3.6, and PyMongo v3.6, v3.7, v3.8.
10-
#
4+
# combinations.
5+
# * Python3.7, MongoDB v3.4 & the latest PyMongo v3.x is currently the "main" setup,
6+
# Other combinations are tested. See below for the details or check the travis jobs
7+
118
# We should periodically check MongoDB Server versions supported by MongoDB
129
# Inc., add newly released versions to the test matrix, and remove versions
1310
# which have reached their End of Life. See:
@@ -16,19 +13,15 @@
1613
#
1714
# Reminder: Update README.rst if you change MongoDB versions we test.
1815

19-
2016
language: python
17+
dist: xenial
2118
python:
22-
- 2.7
2319
- 3.5
2420
- 3.6
2521
- 3.7
2622
- 3.8
27-
- pypy
2823
- pypy3
2924

30-
dist: xenial
31-
3225
env:
3326
global:
3427
- MONGODB_3_4=3.4.17
@@ -39,6 +32,8 @@ env:
3932
- PYMONGO_3_6=3.6
4033
- PYMONGO_3_9=3.9
4134
- PYMONGO_3_10=3.10
35+
36+
- MAIN_PYTHON_VERSION=3.7
4237
matrix:
4338
- MONGODB=${MONGODB_3_4} PYMONGO=${PYMONGO_3_10}
4439

@@ -47,8 +42,6 @@ matrix:
4742
fast_finish: true
4843

4944
include:
50-
- python: 2.7
51-
env: MONGODB=${MONGODB_3_4} PYMONGO=${PYMONGO_3_4}
5245
- python: 3.7
5346
env: MONGODB=${MONGODB_3_6} PYMONGO=${PYMONGO_3_6}
5447
- python: 3.7
@@ -66,29 +59,23 @@ install:
6659
# Install Python dependencies.
6760
- pip install --upgrade pip
6861
- pip install coveralls
69-
- pip install flake8 flake8-import-order
70-
- pip install tox # tox 3.11.0 has requirement virtualenv>=14.0.0
71-
- pip install virtualenv # virtualenv>=14.0.0 has dropped Python 3.2 support (and pypy3 is based on py32)
62+
- pip install pre-commit
63+
- pip install tox
7264
# tox dryrun to setup the tox venv (we run a mock test).
7365
- tox -e $(echo py$TRAVIS_PYTHON_VERSION-mg$PYMONGO | tr -d . | sed -e 's/pypypy/pypy/') -- -a "-k=test_ci_placeholder"
74-
# Install black for Python v3.7 only.
75-
- if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then pip install black; fi
7666

7767
before_script:
7868
- mkdir ${PWD}/mongodb-linux-x86_64-${MONGODB}/data
7969
- ${PWD}/mongodb-linux-x86_64-${MONGODB}/bin/mongod --dbpath ${PWD}/mongodb-linux-x86_64-${MONGODB}/data --logpath ${PWD}/mongodb-linux-x86_64-${MONGODB}/mongodb.log --fork
80-
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then flake8 .; else echo "flake8 only runs on py27"; fi # Run flake8 for Python 2.7 only
81-
- if [[ $TRAVIS_PYTHON_VERSION == '3.7' ]]; then black --check .; else echo "black only runs on py37"; fi # Run black for Python 3.7 only
70+
# Run pre-commit hooks (black, flake8, etc) on entire codebase
71+
- if [[ $TRAVIS_PYTHON_VERSION == $MAIN_PYTHON_VERSION ]]; then pre-commit run -a; else echo "pre-commit checks only runs on py37"; fi
8272
- mongo --eval 'db.version();' # Make sure mongo is awake
8373

8474
script:
8575
- tox -e $(echo py$TRAVIS_PYTHON_VERSION-mg$PYMONGO | tr -d . | sed -e 's/pypypy/pypy/') -- -a "--cov=mongoengine"
8676

87-
# For now only submit coveralls for Python v2.7. Python v3.x currently shows
88-
# 0% coverage. That's caused by 'use_2to3', which builds the py3-compatible
89-
# code in a separate dir and runs tests on that.
9077
after_success:
91-
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then coveralls --verbose; else echo "coveralls only sent for py27"; fi
78+
- - if [[ $TRAVIS_PYTHON_VERSION == $MAIN_PYTHON_VERSION ]]; then coveralls --verbose; else echo "coveralls only sent for py37"; fi
9279

9380
notifications:
9481
irc: irc.freenode.org#mongoengine
@@ -110,11 +97,11 @@ deploy:
11097
distributions: "sdist bdist_wheel"
11198

11299
# Only deploy on tagged commits (aka GitHub releases) and only for the parent
113-
# repo's builds running Python v2.7 along with PyMongo v3.x and MongoDB v3.4.
100+
# repo's builds running Python v3.7 along with PyMongo v3.x and MongoDB v3.4.
114101
# We run Travis against many different Python, PyMongo, and MongoDB versions
115102
# and we don't want the deploy to occur multiple times).
116103
on:
117104
tags: true
118105
repo: MongoEngine/mongoengine
119106
condition: ($PYMONGO = ${PYMONGO_3_10}) && ($MONGODB = ${MONGODB_3_4})
120-
python: 2.7
107+
python: 3.7

CONTRIBUTING.rst

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,43 @@ post to the `user group <http://groups.google.com/group/mongoengine-users>`
2020
Supported Interpreters
2121
----------------------
2222

23-
MongoEngine supports CPython 2.7 and newer. Language
24-
features not supported by all interpreters can not be used.
25-
The codebase is written in python 2 so you must be using python 2
26-
when developing new features. Compatibility of the library with Python 3
27-
relies on the 2to3 package that gets executed as part of the installation
28-
build. You should ensure that your code is properly converted by
29-
`2to3 <http://docs.python.org/library/2to3.html>`_.
23+
MongoEngine supports CPython 3.5 and newer as well as Pypy3.
24+
Language features not supported by all interpreters can not be used.
25+
26+
Python3 codebase
27+
----------------------
28+
29+
Since 0.20, the codebase is exclusively Python 3.
30+
31+
Earlier versions were exclusively Python2, and were relying on 2to3 to support Python3 installs.
32+
Travis runs the tests against the main Python 3.x versions.
33+
3034

3135
Style Guide
3236
-----------
3337

34-
MongoEngine uses `black <https://github.com/python/black>`_ for code
35-
formatting.
38+
MongoEngine's codebase is formatted with `black <https://github.com/python/black>`_, other tools like
39+
flake8 are also used. Those tools will run as part of the CI and will fail in case the code is not formatted properly.
40+
41+
To install all development tools, simply run the following commands:
42+
43+
.. code-block:: console
44+
45+
$ python -m pip install -r requirements-dev.txt
46+
47+
48+
You can install `pre-commit <https://pre-commit.com/>`_ into your git hooks,
49+
to automatically check and fix any formatting issue before creating a
50+
git commit.
51+
52+
To enable ``pre-commit`` simply run:
53+
54+
.. code-block:: console
55+
56+
$ pre-commit install
57+
58+
See the ``.pre-commit-config.yaml`` configuration file for more information
59+
on how it works.
3660

3761
Testing
3862
-------

README.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,22 @@ with MongoDB version > 4.0.
3434
Installation
3535
============
3636
We recommend the use of `virtualenv <https://virtualenv.pypa.io/>`_ and of
37-
`pip <https://pip.pypa.io/>`_. You can then use ``pip install -U mongoengine``.
37+
`pip <https://pip.pypa.io/>`_. You can then use ``python -m pip install -U mongoengine``.
3838
You may also have `setuptools <http://peak.telecommunity.com/DevCenter/setuptools>`_
3939
and thus you can use ``easy_install -U mongoengine``. Another option is
4040
`pipenv <https://docs.pipenv.org/>`_. You can then use ``pipenv install mongoengine``
4141
to both create the virtual environment and install the package. Otherwise, you can
4242
download the source from `GitHub <http://github.com/MongoEngine/mongoengine>`_ and
4343
run ``python setup.py install``.
4444

45+
The support for Python2 was dropped with MongoEngine 0.20.0
46+
4547
Dependencies
4648
============
47-
All of the dependencies can easily be installed via `pip <https://pip.pypa.io/>`_.
49+
All of the dependencies can easily be installed via `python -m pip <https://pip.pypa.io/>`_.
4850
At the very least, you'll need these two packages to use MongoEngine:
4951

5052
- pymongo>=3.4
51-
- six>=1.10.0
5253

5354
If you utilize a ``DateTimeField``, you might also use a more flexible date parser:
5455

@@ -58,6 +59,10 @@ If you need to use an ``ImageField`` or ``ImageGridFsProxy``:
5859

5960
- Pillow>=2.0.0
6061

62+
If you need to use signals:
63+
64+
- blinker>=1.3
65+
6166
Examples
6267
========
6368
Some simple examples of what MongoEngine code looks like:
@@ -125,7 +130,7 @@ installed in your environment and then:
125130
.. code-block:: shell
126131
127132
# Install tox
128-
$ pip install tox
133+
$ python -m pip install tox
129134
# Run the test suites
130135
$ tox
131136

benchmarks/test_inserts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
def main():
55
setup = """
66
from pymongo import MongoClient
7+
78
connection = MongoClient()
89
connection.drop_database('mongoengine_benchmark_test')
910
"""
1011

1112
stmt = """
1213
from pymongo import MongoClient
14+
1315
connection = MongoClient()
1416
1517
db = connection.mongoengine_benchmark_test
@@ -56,6 +58,7 @@ def main():
5658

5759
setup = """
5860
from pymongo import MongoClient
61+
5962
connection = MongoClient()
6063
connection.drop_database('mongoengine_benchmark_test')
6164
connection.close()

docs/changelog.rst

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@ Changelog
66
Development
77
===========
88
- (Fill this out as you fix issues and develop your features).
9+
- ATTENTION: Drop support for Python2
910
- Add Mongo 4.0 to Travis
11+
- Fix error when setting a string as a ComplexDateTimeField #2253
12+
- Bump development Status classifier to Production/Stable #2232
13+
- Improve Queryset.get to avoid confusing MultipleObjectsReturned message in case multiple match are found #630
1014
- Fixed a bug causing inaccurate query results, while combining ``__raw__`` and regular filters for the same field #2264
11-
- Add support for the `elemMatch` projection operator in .fields (e.g BlogPost.objects.fields(elemMatch__comments="test")) #2267
15+
- Add support for the `elemMatch` projection operator in .fields() (e.g BlogPost.objects.fields(elemMatch__comments="test")) #2267
16+
- DictField validate failed without default connection (bug introduced in 0.19.0) #2239
17+
- Remove methods deprecated years ago:
18+
- name parameter in Field constructor e.g `StringField(name="...")`, was replaced by db_field
19+
- Queryset.slave_okay() was deprecated since pymongo3
20+
- dropDups was dropped with MongoDB3
21+
- ``Queryset._ensure_indexes`` and ``Queryset.ensure_indexes``, the right method to use is ``Document.ensure_indexes``
22+
- Added pre-commit #2212
23+
- Renamed requirements-lint.txt to requirements-dev.txt #2212
1224

1325
Changes in 0.19.1
1426
=================

docs/django.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Help Wanted!
1313

1414
The MongoEngine team is looking for help contributing and maintaining a new
1515
Django extension for MongoEngine! If you have Django experience and would like
16-
to help contribute to the project, please get in touch on the
17-
`mailing list <http://groups.google.com/group/mongoengine-users>`_ or by
16+
to help contribute to the project, please get in touch on the
17+
`mailing list <http://groups.google.com/group/mongoengine-users>`_ or by
1818
simply contributing on
1919
`GitHub <https://github.com/MongoEngine/django-mongoengine>`_.

docs/faq.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ If this is a requirement for your project, check the alternative: `uMongo`_ and
1010

1111
.. _uMongo: https://umongo.readthedocs.io/
1212
.. _MotorEngine: https://motorengine.readthedocs.io/
13-

0 commit comments

Comments
 (0)