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

This commit is contained in:
Steven Silvester 2022-02-09 17:19:03 -06:00 committed by GitHub
parent b1d76c8ef4
commit 358e158e40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 107 additions and 20 deletions

2
.git-blame-ignore-revs Normal file
View File

@ -0,0 +1,2 @@
# Initial pre-commit reformat
b1d76c8ef4dd8fd364168c53b5c081b6d053d7b6

40
.github/workflows/test-python.yml vendored Normal file
View File

@ -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/action@v2.0.0
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/mongodb-github-action@1.7.0
with:
mongodb-version: 4.4
- name: Run tests
run: |
python setup.py test

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

@ -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]

View File

@ -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
-------------

View File

@ -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.

View File

@ -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
@ -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
@ -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
@ -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
@ -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

View File

@ -4,4 +4,4 @@
.. automodule:: pymongo.event_loggers
:synopsis: A collection of simple listeners for monitoring driver events.
:members:
:members:

View File

@ -7,4 +7,3 @@
.. autoclass:: pymongo.topology_description.TopologyDescription()
:members:

View File

@ -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

View File

@ -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/

View File

@ -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.

View File

@ -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
@ -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

View File

@ -18,4 +18,4 @@ gT564CmvkUat8uXPz6olOCdwkMpJ9Sj62i0mpgXJdBfxKQ6TZ9yGz6m3jannjZpN
LchB7xSAEWtqUgvNusq0dApJsf4n7jZ+oBZVaQw2+tzaMfaLqHgMwcu1FzA8UKCD
sxCgIsZUs8DdxaD418Ot6nPfheOTqe24n+TTa+Z6O0W0QtnofJBx7tmAo1aEc57i
77s89pfwIJetpIlhzNSMKurCAocFCJMJLAASJFuu6dyDvPo=
-----END CERTIFICATE-----
-----END CERTIFICATE-----