Skip to content

PYTHON-1834 [v4.0] Use a code formatter 2 #856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 9, 2022
Merged
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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Initial pre-commit reformat
b1d76c8ef4dd8fd364168c53b5c081b6d053d7b6
40 changes: 40 additions & 0 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Python Tests

on:
push:
pull_request:

jobs:

pre-commit:
name: pre-commit
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: pre-commit/[email protected]
with:
extra_args: --all-files --hook-stage=manual

build:
# supercharge/mongodb-github-action requires containers so we don't test other platforms
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
python-version: ["3.6", "3.10", "pypy-3.8"]
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: 4.4
- name: Run tests
run: |
python setup.py test
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
exclude: WHEEL
exclude_types: [json]
- id: forbid-new-submodules
- id: trailing-whitespace
exclude: .patch
exclude_types: [json]

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

- repo: https://github.com/PyCQA/isort
rev: 5.7.0
hooks:
- id: isort
files: \.py$
args: [--profile=black]
17 changes: 17 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ General Guidelines
from the cmd line to run the test suite).
- Add yourself to doc/contributors.rst :)

Running Linters
---------------

PyMongo uses `pre-commit <https://pypi.org/project/pre-commit/>`_
for managing linting of the codebase.
``pre-commit`` performs various checks on all files in PyMongo and uses tools
that help follow a consistent code style within the codebase.

To set up ``pre-commit`` locally, run::

pip install pre-commit
pre-commit install

To run ``pre-commit`` manually, run::

pre-commit run --all-files

Documentation
-------------

Expand Down
1 change: 0 additions & 1 deletion THIRD-PARTY-NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,3 @@ supplied in this file in the creation of products supporting the
Unicode Standard, and to make copies of this file in any form
for internal or external distribution as long as this notice
remains attached.

10 changes: 5 additions & 5 deletions bson/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class UuidRepresentation:
code. When decoding a BSON binary field with a UUID subtype, a
:class:`~bson.binary.Binary` instance will be returned instead of a
:class:`uuid.UUID` instance.

See :ref:`unspecified-representation-details` for details.

.. versionadded:: 3.11
Expand All @@ -81,7 +81,7 @@ class UuidRepresentation:
:class:`uuid.UUID` instances will automatically be encoded to
and decoded from BSON binary, using RFC-4122 byte order with
binary subtype :data:`UUID_SUBTYPE`.

See :ref:`standard-representation-details` for details.

.. versionadded:: 3.11
Expand All @@ -93,7 +93,7 @@ class UuidRepresentation:
:class:`uuid.UUID` instances will automatically be encoded to
and decoded from BSON binary, using RFC-4122 byte order with
binary subtype :data:`OLD_UUID_SUBTYPE`.

See :ref:`python-legacy-representation-details` for details.

.. versionadded:: 3.11
Expand All @@ -105,7 +105,7 @@ class UuidRepresentation:
:class:`uuid.UUID` instances will automatically be encoded to
and decoded from BSON binary subtype :data:`OLD_UUID_SUBTYPE`,
using the Java driver's legacy byte order.

See :ref:`java-legacy-representation-details` for details.

.. versionadded:: 3.11
Expand All @@ -117,7 +117,7 @@ class UuidRepresentation:
:class:`uuid.UUID` instances will automatically be encoded to
and decoded from BSON binary subtype :data:`OLD_UUID_SUBTYPE`,
using the C# driver's legacy byte order.

See :ref:`csharp-legacy-representation-details` for details.

.. versionadded:: 3.11
Expand Down
2 changes: 1 addition & 1 deletion doc/api/pymongo/event_loggers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

.. automodule:: pymongo.event_loggers
:synopsis: A collection of simple listeners for monitoring driver events.
:members:
:members:
1 change: 0 additions & 1 deletion doc/api/pymongo/topology_description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@

.. autoclass:: pymongo.topology_description.TopologyDescription()
:members:

1 change: 0 additions & 1 deletion doc/atlas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ Connections to Atlas require TLS/SSL.
.. _homebrew: https://brew.sh/
.. _macports: https://www.macports.org/
.. _requests: https://pypi.python.org/pypi/requests

2 changes: 1 addition & 1 deletion doc/examples/server_selection.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ list of known hosts. As an example, for a 3-member replica set with a
all available secondaries.


.. _server selection algorithm: https://docs.mongodb.com/manual/core/read-preference-mechanics/
.. _server selection algorithm: https://docs.mongodb.com/manual/core/read-preference-mechanics/
2 changes: 1 addition & 1 deletion doc/migrate-to-pymongo4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -950,4 +950,4 @@ Additional BSON classes implement ``__slots__``
:class:`~bson.max_key.MaxKey`, :class:`~bson.timestamp.Timestamp`,
:class:`~bson.regex.Regex`, and :class:`~bson.dbref.DBRef` now implement
``__slots__`` to reduce memory usage. This means that their attributes are fixed, and new
attributes cannot be added to the object at runtime.
attributes cannot be added to the object at runtime.
16 changes: 8 additions & 8 deletions doc/tools.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ Humongolus
possible. The code is available for download
`at GitHub <https://github.com/entone/Humongolus>`_. Tutorials and usage
examples are also available at GitHub.

MincePy
`MincePy <https://mincepy.readthedocs.io/en/latest/>`_ is an
object-document mapper (ODM) designed to make any Python object storable
and queryable in a MongoDB database. It is designed with machine learning
and big-data computational and experimental science applications in mind
but is entirely general and can be useful to anyone looking to organise,
share, or process large amounts data with as little change to their current
`MincePy <https://mincepy.readthedocs.io/en/latest/>`_ is an
object-document mapper (ODM) designed to make any Python object storable
and queryable in a MongoDB database. It is designed with machine learning
and big-data computational and experimental science applications in mind
but is entirely general and can be useful to anyone looking to organise,
share, or process large amounts data with as little change to their current
workflow as possible.

Ming
Expand All @@ -80,7 +80,7 @@ MotorEngine
It implements the same modeling APIs to be data-portable, meaning that a
model defined in MongoEngine can be read in MotorEngine. The source is
`available on GitHub <http://github.com/heynemann/motorengine>`_.

uMongo
`uMongo <https://umongo.readthedocs.io/>`_ is a Python MongoDB ODM.
Its inception comes from two needs: the lack of async ODM and the
Expand Down
2 changes: 1 addition & 1 deletion test/certificates/ca.pem
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ gT564CmvkUat8uXPz6olOCdwkMpJ9Sj62i0mpgXJdBfxKQ6TZ9yGz6m3jannjZpN
LchB7xSAEWtqUgvNusq0dApJsf4n7jZ+oBZVaQw2+tzaMfaLqHgMwcu1FzA8UKCD
sxCgIsZUs8DdxaD418Ot6nPfheOTqe24n+TTa+Z6O0W0QtnofJBx7tmAo1aEc57i
77s89pfwIJetpIlhzNSMKurCAocFCJMJLAASJFuu6dyDvPo=
-----END CERTIFICATE-----
-----END CERTIFICATE-----