Merge branch 'fix/add-dev-tools' of git://github.com/Pacu2/mongoengine into Pacu2-fix/add-dev-tools

This commit is contained in:
Bastien Gérard 2020-04-25 20:46:44 +02:00
commit 4085bc2152
16 changed files with 64 additions and 26 deletions

13
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,13 @@
repos:
- repo: https://github.com/ambv/black
rev: 19.3b0
hooks:
- id: black
language_version: python3
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: flake8

View File

@ -31,8 +31,28 @@ build. You should ensure that your code is properly converted by
Style Guide Style Guide
----------- -----------
MongoEngine uses `black <https://github.com/python/black>`_ for code MongoEngine uses various tools to maintain a common coding style.
formatting.
To install all development tools, simply run the following commands:
.. code-block:: console
$ python -m pip install -r requirements-dev.txt
You can install `pre-commit <https://pre-commit.com/>`_ into your git hooks,
to automatically check and fix any formatting issue before creating a
git commit.
To enable ``pre-commit`` simply run:
.. code-block:: console
$ pre-commit install
See the ``.pre-commit-config.yaml`` configuration file for more information
on how it works.
Testing Testing
------- -------

View File

@ -34,7 +34,7 @@ with MongoDB version > 4.0.
Installation Installation
============ ============
We recommend the use of `virtualenv <https://virtualenv.pypa.io/>`_ and of We recommend the use of `virtualenv <https://virtualenv.pypa.io/>`_ and of
`pip <https://pip.pypa.io/>`_. You can then use ``pip install -U mongoengine``. `pip <https://pip.pypa.io/>`_. You can then use ``python -m pip install -U mongoengine``.
You may also have `setuptools <http://peak.telecommunity.com/DevCenter/setuptools>`_ You may also have `setuptools <http://peak.telecommunity.com/DevCenter/setuptools>`_
and thus you can use ``easy_install -U mongoengine``. Another option is and thus you can use ``easy_install -U mongoengine``. Another option is
`pipenv <https://docs.pipenv.org/>`_. You can then use ``pipenv install mongoengine`` `pipenv <https://docs.pipenv.org/>`_. You can then use ``pipenv install mongoengine``
@ -44,7 +44,7 @@ run ``python setup.py install``.
Dependencies Dependencies
============ ============
All of the dependencies can easily be installed via `pip <https://pip.pypa.io/>`_. All of the dependencies can easily be installed via `python -m pip <https://pip.pypa.io/>`_.
At the very least, you'll need these two packages to use MongoEngine: At the very least, you'll need these two packages to use MongoEngine:
- pymongo>=3.4 - pymongo>=3.4
@ -125,7 +125,7 @@ installed in your environment and then:
.. code-block:: shell .. code-block:: shell
# Install tox # Install tox
$ pip install tox $ python -m pip install tox
# Run the test suites # Run the test suites
$ tox $ tox

View File

@ -16,6 +16,8 @@ Development
- Queryset.slave_okay() was deprecated since pymongo3 - Queryset.slave_okay() was deprecated since pymongo3
- dropDups was dropped with MongoDB3 - dropDups was dropped with MongoDB3
- ``Queryset._ensure_indexes`` and ``Queryset.ensure_indexes``, the right method to use is ``Document.ensure_indexes`` - ``Queryset._ensure_indexes`` and ``Queryset.ensure_indexes``, the right method to use is ``Document.ensure_indexes``
- Added pre-commit #2212
- Renamed requirements-lint.txt to requirements-dev.txt #2212
Changes in 0.19.1 Changes in 0.19.1
================= =================

View File

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

View File

@ -10,4 +10,3 @@ If this is a requirement for your project, check the alternative: `uMongo`_ and
.. _uMongo: https://umongo.readthedocs.io/ .. _uMongo: https://umongo.readthedocs.io/
.. _MotorEngine: https://motorengine.readthedocs.io/ .. _MotorEngine: https://motorengine.readthedocs.io/

View File

@ -86,7 +86,7 @@ using 3 different databases to store data::
connect(alias='user-db-alias', db='user-db') connect(alias='user-db-alias', db='user-db')
connect(alias='book-db-alias', db='book-db') connect(alias='book-db-alias', db='book-db')
connect(alias='users-books-db-alias', db='users-books-db') connect(alias='users-books-db-alias', db='users-books-db')
class User(Document): class User(Document):
name = StringField() name = StringField()

View File

@ -12,7 +12,7 @@ MongoEngine is available on PyPI, so you can use :program:`pip`:
.. code-block:: console .. code-block:: console
$ pip install mongoengine $ python -m pip install mongoengine
Alternatively, if you don't have setuptools installed, `download it from PyPi Alternatively, if you don't have setuptools installed, `download it from PyPi
<http://pypi.python.org/pypi/mongoengine/>`_ and run <http://pypi.python.org/pypi/mongoengine/>`_ and run

View File

@ -44,8 +44,8 @@ Available signals include:
`post_save` `post_save`
Called within :meth:`~mongoengine.Document.save` after most actions Called within :meth:`~mongoengine.Document.save` after most actions
(validation, insert/update, and cascades, but not clearing dirty flags) have (validation, insert/update, and cascades, but not clearing dirty flags) have
completed successfully. Passed the additional boolean keyword argument completed successfully. Passed the additional boolean keyword argument
`created` to indicate if the save was an insert or an update. `created` to indicate if the save was an insert or an update.
`pre_delete` `pre_delete`

View File

@ -8,7 +8,7 @@ After MongoDB 2.4 version, supports search documents by text indexes.
Defining a Document with text index Defining a Document with text index
=================================== ===================================
Use the *$* prefix to set a text index, Look the declaration:: Use the *$* prefix to set a text index, Look the declaration::
class News(Document): class News(Document):
title = StringField() title = StringField()
content = StringField() content = StringField()
@ -35,10 +35,10 @@ Saving a document::
content="Various improvements").save() content="Various improvements").save()
Next, start a text search using :attr:`QuerySet.search_text` method:: Next, start a text search using :attr:`QuerySet.search_text` method::
document = News.objects.search_text('testing').first() document = News.objects.search_text('testing').first()
document.title # may be: "Using mongodb text search" document.title # may be: "Using mongodb text search"
document = News.objects.search_text('released').first() document = News.objects.search_text('released').first()
document.title # may be: "MongoEngine 0.9 released" document.title # may be: "MongoEngine 0.9 released"

View File

@ -7,7 +7,7 @@ MongoDB. To install it, simply run
.. code-block:: console .. code-block:: console
$ pip install -U mongoengine $ python -m pip install -U mongoengine
:doc:`tutorial` :doc:`tutorial`
A quick tutorial building a tumblelog to get you up and running with A quick tutorial building a tumblelog to get you up and running with
@ -91,4 +91,3 @@ Indices and tables
* :ref:`genindex` * :ref:`genindex`
* :ref:`modindex` * :ref:`modindex`
* :ref:`search` * :ref:`search`

View File

@ -18,7 +18,7 @@ location --- running it locally will be easier, but if that is not an option
then it may be run on a remote server. If you haven't installed MongoEngine, then it may be run on a remote server. If you haven't installed MongoEngine,
simply use pip to install it like so:: simply use pip to install it like so::
$ pip install mongoengine $ python -m pip install mongoengine
Before we can start using MongoEngine, we need to tell it how to connect to our Before we can start using MongoEngine, we need to tell it how to connect to our
instance of :program:`mongod`. For this we use the :func:`~mongoengine.connect` instance of :program:`mongod`. For this we use the :func:`~mongoengine.connect`

View File

@ -85,10 +85,10 @@ by default from now on.
The 0.8.7 package on pypi was corrupted. If upgrading from 0.8.7 to 0.9.0 please follow: :: The 0.8.7 package on pypi was corrupted. If upgrading from 0.8.7 to 0.9.0 please follow: ::
pip uninstall pymongo python -m pip uninstall pymongo
pip uninstall mongoengine python -m pip uninstall mongoengine
pip install pymongo==2.8 python -m pip install pymongo==2.8
pip install mongoengine python -m pip install mongoengine
0.8.7 0.8.7
***** *****

View File

@ -51,4 +51,4 @@ rm -rf $RPM_BUILD_ROOT
# %{python_sitearch}/* # %{python_sitearch}/*
%changelog %changelog
* See: http://docs.mongoengine.org/en/latest/changelog.html * See: http://docs.mongoengine.org/en/latest/changelog.html

8
requirements-dev.txt Normal file
View File

@ -0,0 +1,8 @@
black
flake8
flake8-import-order
pre-commit
pytest
ipdb
ipython
tox

View File

@ -1,3 +0,0 @@
black
flake8
flake8-import-order