Skip to content

Commit 358e158

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

File tree

13 files changed

+107
-20
lines changed

13 files changed

+107
-20
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Initial pre-commit reformat
2+
b1d76c8ef4dd8fd364168c53b5c081b6d053d7b6

.github/workflows/test-python.yml

Lines changed: 40 additions & 0 deletions
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

Lines changed: 31 additions & 0 deletions
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

Lines changed: 17 additions & 0 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 5 additions & 5 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/

0 commit comments

Comments
 (0)