Skip to content

Commit

Permalink
Merge branch 'master' into MOTOR-1209
Browse files Browse the repository at this point in the history
  • Loading branch information
Jibola committed Nov 13, 2023
2 parents b519699 + 546f754 commit 3a40567
Show file tree
Hide file tree
Showing 38 changed files with 374 additions and 326 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,12 @@ jobs:
typing:
name: Typing Tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.12']
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
python-version: "3.10"
cache: 'pip'
cache-dependency-path: 'pyproject.toml'
allow-prereleases: true
Expand Down
63 changes: 52 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: check-yaml
exclude: template.yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: WHEEL
Expand All @@ -16,34 +17,74 @@ repos:
exclude: .patch
exclude_types: [json]

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
files: \.(py|pyi)$
args: [--line-length=100]

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.1
rev: v0.1.3
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
- id: ruff-format

- repo: https://github.com/adamchainz/blacken-docs
rev: "1.16.0"
hooks:
- id: blacken-docs
additional_dependencies:
- black==22.3.0

- repo: https://github.com/pre-commit/pygrep-hooks
rev: "v1.10.0"
hooks:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/rstcheck/rstcheck
rev: v6.2.0
hooks:
- id: rstcheck
additional_dependencies: [sphinx]
args: ["--ignore-directives=doctest,testsetup,todo,automodule,mongodoc,autodoc,testcleanup,autoclass","--ignore-substitutions=release", "--report-level=error"]
exclude: '^doc/migrate-to-motor-3.rst'

# We use the Python version instead of the original version which seems to require Docker
# https://github.com/koalaman/shellcheck-precommit
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.8.0.4
rev: v0.9.0.6
hooks:
- id: shellcheck
name: shellcheck
args: ["--severity=warning"]
stages: [manual]

- repo: https://github.com/PyCQA/doc8
rev: v1.1.1
hooks:
- id: doc8
args: ["--ignore=D001"] # ignore line length
stages: [manual]

- repo: https://github.com/sirosen/check-jsonschema
rev: 0.14.1
rev: 0.27.0
hooks:
- id: check-jsonschema
name: "Check GitHub Workflows"
files: ^\.github/workflows/
types: [yaml]
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]

- repo: https://github.com/ariebovenberg/slotscheck
rev: v0.17.0
hooks:
- id: slotscheck
files: \.py$
exclude: "^(doc|test)/"
stages: [manual]
args: ["--no-strict-imports"]


- repo: https://github.com/codespell-project/codespell
rev: "v2.2.6"
hooks:
- id: codespell
args: ["-L", "fle"]
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
include README.rst
include LICENSE
include tox.ini
include pytest.ini
include pyproject.toml
include mypy.ini
include doc/Makefile
include doc/examples/tornado_change_stream_templates/index.html
recursive-include doc *.rst
Expand Down
8 changes: 4 additions & 4 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ and a `source distribution <https://packaging.python.org/guides/distributing-pac

#. Check JIRA to ensure all the tickets in this version have been completed.

#. Add release notes to `doc/changelog.rst`. Generally just summarize/clarify
#. Add release notes to ``doc/changelog.rst``. Generally just summarize/clarify
the git log, but you might add some more long form notes for big changes.

#. Replace the `devN` version number w/ the new version number (see
#. Replace the ``devN`` version number w/ the new version number (see
note above in `Versioning`_). Make sure version number is updated in
``motor/_version.py``. Commit the change and tag the release.
Immediately bump the version number to `dev0` in a new commit::
Immediately bump the version number to ``dev0`` in a new commit::

$ # Bump to release version number
$ git commit -a -m "BUMP <release version number>"
Expand All @@ -45,7 +45,7 @@ and a `source distribution <https://packaging.python.org/guides/distributing-pac
$ git push
$ git push --tags

#. Build the release packages by running the `release.sh`
#. Build the release packages by running the ``release.sh``
script on macOS::

$ git clone [email protected]:mongodb/motor.git
Expand Down
56 changes: 28 additions & 28 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ New features:

The new Queryable Encryption changes that are in beta are:

- The `encrypted_fields` argument to the
- The ``encrypted_fields`` argument to the
:class:`~motor.motor_tornado.MotorCollection` constructor, and the
:meth:`~motor.motor_tornado.MotorDatabase.create_collection`
and :meth:`~motor.motor_tornado.MotorDatabase.drop_collection` methods.
- The `query_type` and `contention_factor` arguments to
- The ``query_type`` and ``contention_factor`` arguments to
:meth:`motor.motor_asyncio.AsyncIOMotorClientEncryption.encrypt` and
:meth:`motor.motor_tornado.MotorClientEncryption.encrypt`.

Expand All @@ -87,7 +87,7 @@ Motor 3.0
---------

Motor 3.0 adds support for PyMongo 4.0+. It inherits a number
of improvemnts and breaking API changes from PyMongo 4.0+.
of improvements and breaking API changes from PyMongo 4.0+.
See :doc:`migrate-to-motor-3` for more information.

Breaking Changes
Expand Down Expand Up @@ -167,7 +167,7 @@ Breaking Changes
- Comparing two :class:`~motor.motor_tornado.MotorClient` instances now
uses a set of immutable properties rather than
:attr:`~motor.motor_tornado.MotorClient.address` which can change.
- Removed the `disable_md5` parameter for :class:`~gridfs.GridFSBucket` and
- Removed the ``disable_md5`` parameter for :class:`~gridfs.GridFSBucket` and
:class:`~gridfs.GridFS`. See :ref:`removed-gridfs-checksum` for details.
- PyMongoCrypt 1.2.0 or later is now required for client side field level
encryption support.
Expand All @@ -180,10 +180,10 @@ Notable improvements
- Added the ``maxConnecting`` URI and
:class:`~motor.motor_tornado.MotorClient` keyword argument.
- :class:`~motor.motor_tornado.MotorClient` now accepts a URI and keyword
argument `srvMaxHosts` that limits the number of mongos-like hosts a client
argument ``srvMaxHosts`` that limits the number of mongos-like hosts a client
will connect to. More specifically, when a mongodb+srv:// connection string
resolves to more than `srvMaxHosts` number of hosts, the client will randomly
choose a `srvMaxHosts` sized subset of hosts.
resolves to more than ``srvMaxHosts`` number of hosts, the client will randomly
choose a ``srvMaxHosts`` sized subset of hosts.
- Added :attr:`motor.motor_tornado.MotorClient.options` for read-only access
to a client's configuration options.
- Added support for the ``comment`` parameter to all helpers. For example see
Expand Down Expand Up @@ -666,7 +666,7 @@ Highlights include:
verification.
- TLS compression is now explicitly disabled when possible.
- The Server Name Indication (SNI) TLS extension is used when possible.
- PyMongo's `bson` module provides finer control over JSON encoding/decoding
- PyMongo's ``bson`` module provides finer control over JSON encoding/decoding
with :class:`~bson.json_util.JSONOptions`.
- Allow :class:`~bson.code.Code` objects to have a scope of ``None``,
signifying no scope. Also allow encoding Code objects with an empty scope
Expand Down Expand Up @@ -738,8 +738,8 @@ Unix domain socket paths must be quoted with :func:`urllib.parse.quote_plus` (or

.. code-block:: python
path = '/tmp/mongodb-27017.sock'
MotorClient('mongodb://%s' % urllib.parse.quote_plus(path))
path = "/tmp/mongodb-27017.sock"
MotorClient("mongodb://%s" % urllib.parse.quote_plus(path))
:class:`~motor.motor_tornado.MotorCollection` changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -1015,20 +1015,20 @@ Motor 0.6
This is a bugfix release. Fixing these bugs has introduced tiny API changes that
may affect some programs.

`motor_asyncio` and `motor_tornado` submodules
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
``motor_asyncio`` and ``motor_tornado`` submodules
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

These modules have been moved from:

- `motor_asyncio.py`
- `motor_tornado.py`
- ``motor_asyncio.py``
- ``motor_tornado.py``

To:

- `motor_asyncio/__init__.py`
- `motor_tornado/__init__.py`
- ``motor_asyncio/__init__.py``
- ``motor_tornado/__init__.py``

Motor had to make this change in order to omit the `motor_asyncio` submodule
Motor had to make this change in order to omit the ``motor_asyncio`` submodule
entirely and avoid a spurious :exc:`SyntaxError` being printed when installing in
Python 2. The change should be invisible to application code.

Expand Down Expand Up @@ -1082,18 +1082,18 @@ explanation.)

.. _commit message dc19418c: https://github.com/mongodb/motor/commit/dc19418c

`async` and `await`
~~~~~~~~~~~~~~~~~~~
``async`` and ``await``
~~~~~~~~~~~~~~~~~~~~~~~

Motor now supports Python 3.5 native coroutines, written with the `async` and
`await` syntax::
Motor now supports Python 3.5 native coroutines, written with the ``async`` and
``await`` syntax::

async def f():
await collection.insert({'_id': 1})

Cursors from :meth:`~MotorCollection.find`, :meth:`~MotorCollection.aggregate`, or
:meth:`~MotorGridFS.find` can be iterated elegantly and very efficiently in native
coroutines with `async for`::
coroutines with ``async for``::

async def f():
async for doc in collection.find():
Expand All @@ -1105,7 +1105,7 @@ coroutines with `async for`::
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:meth:`MotorCollection.aggregate` now returns a cursor by default, and the cursor
is returned immediately without a `yield`. The old syntax is no longer
is returned immediately without a ``yield``. The old syntax is no longer
supported::

# Motor 0.4 and older, no longer supported.
Expand Down Expand Up @@ -1143,7 +1143,7 @@ Deprecations

Motor 0.5 deprecates a large number of APIs that will be removed in version 1.0:

`MotorClient`:
``MotorClient``:
- `~MotorClient.host`
- `~MotorClient.port`
- `~MotorClient.document_class`
Expand All @@ -1154,20 +1154,20 @@ Motor 0.5 deprecates a large number of APIs that will be removed in version 1.0:
- `~MotorClient.disconnect`
- `~MotorClient.alive`

`MotorReplicaSetClient`:
``MotorReplicaSetClient``:
- `~MotorReplicaSetClient.document_class`
- `~MotorReplicaSetClient.tz_aware`
- `~MotorReplicaSetClient.secondary_acceptable_latency_ms`
- `~MotorReplicaSetClient.tag_sets`
- `~MotorReplicaSetClient.uuid_subtype`
- `~MotorReplicaSetClient.alive`

`MotorDatabase`:
``MotorDatabase``:
- `~MotorDatabase.secondary_acceptable_latency_ms`
- `~MotorDatabase.tag_sets`
- `~MotorDatabase.uuid_subtype`

`MotorCollection`:
``MotorCollection``:
- `~MotorCollection.secondary_acceptable_latency_ms`
- `~MotorCollection.tag_sets`
- `~MotorCollection.uuid_subtype`
Expand Down Expand Up @@ -1197,7 +1197,7 @@ SSL hostname validation error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When you use Motor with Tornado and SSL hostname validation fails, Motor used
to raise a :exc:`~pymongo.errors.ConnectionFailure` with a useful messsage like "hostname 'X'
to raise a :exc:`~pymongo.errors.ConnectionFailure` with a useful message like "hostname 'X'
doesn't match 'Y'". The message is now empty and Tornado logs a warning
instead.

Expand Down
20 changes: 5 additions & 15 deletions doc/differences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ system_js

PyMongo supports Javascript procedures stored in MongoDB with syntax like:

.. code-block:: python
.. code-block:: pycon
>>> db.system_js.my_func = 'function(x) { return x * x; }'
>>> db.system_js.my_func = "function(x) { return x * x; }"
>>> db.system_js.my_func(2)
4.0
Expand Down Expand Up @@ -133,25 +133,15 @@ There are two ways to create a capped collection using PyMongo:
.. code-block:: python
# Typical:
db.create_collection(
'collection1',
capped=True,
size=1000)
db.create_collection("collection1", capped=True, size=1000)
# Unusual:
collection = Collection(
db,
'collection2',
capped=True,
size=1000)
collection = Collection(db, "collection2", capped=True, size=1000)
Motor can't do I/O in a constructor, so the unusual style is prohibited and
only the typical style is allowed:

.. code-block:: python
async def f():
await db.create_collection(
'collection1',
capped=True,
size=1000)
await db.create_collection("collection1", capped=True, size=1000)
1 change: 1 addition & 0 deletions doc/examples/aiohttp_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ async def page_handler(request):

# -- handler-end --


# -- main-start --
async def init_connection():
db = await setup_db()
Expand Down
Loading

0 comments on commit 3a40567

Please sign in to comment.