Skip to content

Commit 358e158

Browse files
authored
PYTHON-1834 [v4.0] Use a code formatter 2 (#856)
1 parent b1d76c8 commit 358e158

13 files changed

+107
-20
lines changed

.git-blame-ignore-revs

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Initial pre-commit reformat
2+
b1d76c8ef4dd8fd364168c53b5c081b6d053d7b6

.github/workflows/test-python.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Python Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
9+
pre-commit:
10+
name: pre-commit
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-python@v2
16+
- uses: pre-commit/[email protected]
17+
with:
18+
extra_args: --all-files --hook-stage=manual
19+
20+
build:
21+
# supercharge/mongodb-github-action requires containers so we don't test other platforms
22+
runs-on: ${{ matrix.os }}
23+
strategy:
24+
matrix:
25+
os: [ubuntu-20.04]
26+
python-version: ["3.6", "3.10", "pypy-3.8"]
27+
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
28+
steps:
29+
- uses: actions/checkout@v2
30+
- name: Setup Python
31+
uses: actions/setup-python@v2
32+
with:
33+
python-version: ${{ matrix.python-version }}
34+
- name: Start MongoDB
35+
uses: supercharge/[email protected]
36+
with:
37+
mongodb-version: 4.4
38+
- name: Run tests
39+
run: |
40+
python setup.py test

.pre-commit-config.yaml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v3.4.0
5+
hooks:
6+
- id: check-added-large-files
7+
- id: check-case-conflict
8+
- id: check-toml
9+
- id: check-yaml
10+
- id: debug-statements
11+
- id: end-of-file-fixer
12+
exclude: WHEEL
13+
exclude_types: [json]
14+
- id: forbid-new-submodules
15+
- id: trailing-whitespace
16+
exclude: .patch
17+
exclude_types: [json]
18+
19+
- repo: https://github.com/psf/black
20+
rev: 22.1.0
21+
hooks:
22+
- id: black
23+
files: \.py$
24+
args: [--line-length=100]
25+
26+
- repo: https://github.com/PyCQA/isort
27+
rev: 5.7.0
28+
hooks:
29+
- id: isort
30+
files: \.py$
31+
args: [--profile=black]

CONTRIBUTING.rst

+17
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ General Guidelines
3838
from the cmd line to run the test suite).
3939
- Add yourself to doc/contributors.rst :)
4040

41+
Running Linters
42+
---------------
43+
44+
PyMongo uses `pre-commit <https://pypi.org/project/pre-commit/>`_
45+
for managing linting of the codebase.
46+
``pre-commit`` performs various checks on all files in PyMongo and uses tools
47+
that help follow a consistent code style within the codebase.
48+
49+
To set up ``pre-commit`` locally, run::
50+
51+
pip install pre-commit
52+
pre-commit install
53+
54+
To run ``pre-commit`` manually, run::
55+
56+
pre-commit run --all-files
57+
4158
Documentation
4259
-------------
4360

THIRD-PARTY-NOTICES

-1
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,3 @@ supplied in this file in the creation of products supporting the
9494
Unicode Standard, and to make copies of this file in any form
9595
for internal or external distribution as long as this notice
9696
remains attached.
97-

bson/binary.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class UuidRepresentation:
6969
code. When decoding a BSON binary field with a UUID subtype, a
7070
:class:`~bson.binary.Binary` instance will be returned instead of a
7171
:class:`uuid.UUID` instance.
72-
72+
7373
See :ref:`unspecified-representation-details` for details.
7474
7575
.. versionadded:: 3.11
@@ -81,7 +81,7 @@ class UuidRepresentation:
8181
:class:`uuid.UUID` instances will automatically be encoded to
8282
and decoded from BSON binary, using RFC-4122 byte order with
8383
binary subtype :data:`UUID_SUBTYPE`.
84-
84+
8585
See :ref:`standard-representation-details` for details.
8686
8787
.. versionadded:: 3.11
@@ -93,7 +93,7 @@ class UuidRepresentation:
9393
:class:`uuid.UUID` instances will automatically be encoded to
9494
and decoded from BSON binary, using RFC-4122 byte order with
9595
binary subtype :data:`OLD_UUID_SUBTYPE`.
96-
96+
9797
See :ref:`python-legacy-representation-details` for details.
9898
9999
.. versionadded:: 3.11
@@ -105,7 +105,7 @@ class UuidRepresentation:
105105
:class:`uuid.UUID` instances will automatically be encoded to
106106
and decoded from BSON binary subtype :data:`OLD_UUID_SUBTYPE`,
107107
using the Java driver's legacy byte order.
108-
108+
109109
See :ref:`java-legacy-representation-details` for details.
110110
111111
.. versionadded:: 3.11
@@ -117,7 +117,7 @@ class UuidRepresentation:
117117
:class:`uuid.UUID` instances will automatically be encoded to
118118
and decoded from BSON binary subtype :data:`OLD_UUID_SUBTYPE`,
119119
using the C# driver's legacy byte order.
120-
120+
121121
See :ref:`csharp-legacy-representation-details` for details.
122122
123123
.. versionadded:: 3.11

doc/api/pymongo/event_loggers.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
.. automodule:: pymongo.event_loggers
66
:synopsis: A collection of simple listeners for monitoring driver events.
7-
:members:
7+
:members:

doc/api/pymongo/topology_description.rst

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@
77

88
.. autoclass:: pymongo.topology_description.TopologyDescription()
99
:members:
10-

doc/atlas.rst

-1
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,3 @@ Connections to Atlas require TLS/SSL.
4141
.. _homebrew: https://brew.sh/
4242
.. _macports: https://www.macports.org/
4343
.. _requests: https://pypi.python.org/pypi/requests
44-

doc/examples/server_selection.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,4 @@ list of known hosts. As an example, for a 3-member replica set with a
105105
all available secondaries.
106106

107107

108-
.. _server selection algorithm: https://docs.mongodb.com/manual/core/read-preference-mechanics/
108+
.. _server selection algorithm: https://docs.mongodb.com/manual/core/read-preference-mechanics/

doc/migrate-to-pymongo4.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -950,4 +950,4 @@ Additional BSON classes implement ``__slots__``
950950
:class:`~bson.max_key.MaxKey`, :class:`~bson.timestamp.Timestamp`,
951951
:class:`~bson.regex.Regex`, and :class:`~bson.dbref.DBRef` now implement
952952
``__slots__`` to reduce memory usage. This means that their attributes are fixed, and new
953-
attributes cannot be added to the object at runtime.
953+
attributes cannot be added to the object at runtime.

doc/tools.rst

+8-8
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ Humongolus
4747
possible. The code is available for download
4848
`at GitHub <https://github.com/entone/Humongolus>`_. Tutorials and usage
4949
examples are also available at GitHub.
50-
50+
5151
MincePy
52-
`MincePy <https://mincepy.readthedocs.io/en/latest/>`_ is an
53-
object-document mapper (ODM) designed to make any Python object storable
54-
and queryable in a MongoDB database. It is designed with machine learning
55-
and big-data computational and experimental science applications in mind
56-
but is entirely general and can be useful to anyone looking to organise,
57-
share, or process large amounts data with as little change to their current
52+
`MincePy <https://mincepy.readthedocs.io/en/latest/>`_ is an
53+
object-document mapper (ODM) designed to make any Python object storable
54+
and queryable in a MongoDB database. It is designed with machine learning
55+
and big-data computational and experimental science applications in mind
56+
but is entirely general and can be useful to anyone looking to organise,
57+
share, or process large amounts data with as little change to their current
5858
workflow as possible.
5959

6060
Ming
@@ -80,7 +80,7 @@ MotorEngine
8080
It implements the same modeling APIs to be data-portable, meaning that a
8181
model defined in MongoEngine can be read in MotorEngine. The source is
8282
`available on GitHub <http://github.com/heynemann/motorengine>`_.
83-
83+
8484
uMongo
8585
`uMongo <https://umongo.readthedocs.io/>`_ is a Python MongoDB ODM.
8686
Its inception comes from two needs: the lack of async ODM and the

test/certificates/ca.pem

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ gT564CmvkUat8uXPz6olOCdwkMpJ9Sj62i0mpgXJdBfxKQ6TZ9yGz6m3jannjZpN
1818
LchB7xSAEWtqUgvNusq0dApJsf4n7jZ+oBZVaQw2+tzaMfaLqHgMwcu1FzA8UKCD
1919
sxCgIsZUs8DdxaD418Ot6nPfheOTqe24n+TTa+Z6O0W0QtnofJBx7tmAo1aEc57i
2020
77s89pfwIJetpIlhzNSMKurCAocFCJMJLAASJFuu6dyDvPo=
21-
-----END CERTIFICATE-----
21+
-----END CERTIFICATE-----

0 commit comments

Comments
 (0)