Skip to content

Commit 226049f

Browse files
committed
Merge branch 'master' of github.com:MongoEngine/mongoengine into DonQueso89-master
2 parents dc1cf88 + f5f8b73 commit 226049f

26 files changed

+122
-66
lines changed

.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: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ env:
3333
- PYMONGO_3_9=3.9
3434
- PYMONGO_3_10=3.10
3535

36-
- MAIN_PYTHON_VERSION = "3.7"
36+
- MAIN_PYTHON_VERSION=3.7
3737
matrix:
3838
- MONGODB=${MONGODB_3_4} PYMONGO=${PYMONGO_3_10}
3939

@@ -59,18 +59,16 @@ install:
5959
# Install Python dependencies.
6060
- pip install --upgrade pip
6161
- pip install coveralls
62-
- pip install flake8 flake8-import-order
62+
- pip install pre-commit
6363
- pip install tox
6464
# tox dryrun to setup the tox venv (we run a mock test).
6565
- tox -e $(echo py$TRAVIS_PYTHON_VERSION-mg$PYMONGO | tr -d . | sed -e 's/pypypy/pypy/') -- -a "-k=test_ci_placeholder"
66-
# Install black for Python v3.7 only.
67-
- if [[ $TRAVIS_PYTHON_VERSION == $MAIN_PYTHON_VERSION ]]; then pip install black; fi
6866

6967
before_script:
7068
- mkdir ${PWD}/mongodb-linux-x86_64-${MONGODB}/data
7169
- ${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
72-
- if [[ $TRAVIS_PYTHON_VERSION == $MAIN_PYTHON_VERSION ]]; then flake8 .; else echo "flake8 only runs on py37"; fi
73-
- if [[ $TRAVIS_PYTHON_VERSION == $MAIN_PYTHON_VERSION ]]; then black --check .; else echo "black only runs on py37"; fi
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
7472
- mongo --eval 'db.version();' # Make sure mongo is awake
7573

7674
script:

CONTRIBUTING.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,28 @@ Travis runs the tests against the main Python 3.x versions.
3535
Style Guide
3636
-----------
3737

38-
MongoEngine uses `black <https://github.com/python/black>`_ for code formatting.
39-
Black runs as part of the CI so it will fail in case the code is not formatted properly.
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.
4060

4161
Testing
4262
-------

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ 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``
@@ -46,7 +46,7 @@ The support for Python2 was dropped with MongoEngine 0.20.0
4646

4747
Dependencies
4848
============
49-
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/>`_.
5050
At the very least, you'll need these two packages to use MongoEngine:
5151

5252
- pymongo>=3.4
@@ -130,7 +130,7 @@ installed in your environment and then:
130130
.. code-block:: shell
131131
132132
# Install tox
133-
$ pip install tox
133+
$ python -m pip install tox
134134
# Run the test suites
135135
$ tox
136136

docs/changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Development
88
- (Fill this out as you fix issues and develop your features).
99
- ATTENTION: Drop support for Python2
1010
- Add Mongo 4.0 to Travis
11+
- Fix error when setting a string as a ComplexDateTimeField #2253
1112
- Bump development Status classifier to Production/Stable #2232
1213
- Improve Queryset.get to avoid confusing MultipleObjectsReturned message in case multiple match are found #630
1314
- Fixed a bug causing inaccurate query results, while combining ``__raw__`` and regular filters for the same field #2264
@@ -18,6 +19,8 @@ Development
1819
- Queryset.slave_okay() was deprecated since pymongo3
1920
- dropDups was dropped with MongoDB3
2021
- ``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
2124

2225
Changes in 0.19.1
2326
=================

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-

docs/guide/connecting.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ using 3 different databases to store data::
8686
connect(alias='user-db-alias', db='user-db')
8787
connect(alias='book-db-alias', db='book-db')
8888
connect(alias='users-books-db-alias', db='users-books-db')
89-
89+
9090
class User(Document):
9191
name = StringField()
9292

docs/guide/installing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ MongoEngine is available on PyPI, so you can use :program:`pip`:
1212

1313
.. code-block:: console
1414
15-
$ pip install mongoengine
15+
$ python -m pip install mongoengine
1616
1717
Alternatively, if you don't have setuptools installed, `download it from PyPi
1818
<http://pypi.python.org/pypi/mongoengine/>`_ and run

docs/guide/signals.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Available signals include:
4444

4545
`post_save`
4646
Called within :meth:`~mongoengine.Document.save` after most actions
47-
(validation, insert/update, and cascades, but not clearing dirty flags) have
48-
completed successfully. Passed the additional boolean keyword argument
47+
(validation, insert/update, and cascades, but not clearing dirty flags) have
48+
completed successfully. Passed the additional boolean keyword argument
4949
`created` to indicate if the save was an insert or an update.
5050

5151
`pre_delete`

0 commit comments

Comments
 (0)