Skip to content

Commit b7057ec

Browse files
authored
PYTHON-1834 (cont) Add pre-commit config (mongodb#853)
1 parent 5578999 commit b7057ec

File tree

12 files changed

+75
-16
lines changed

12 files changed

+75
-16
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+
5578999a90e439fbca06fc0ffc98f4d04e96f7b4

.github/workflows/test-python.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ on:
55
pull_request:
66

77
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+
820
build:
921
# supercharge/mongodb-github-action requires containers so we don't test other platforms
1022
runs-on: ${{ matrix.os }}

.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: 18 additions & 1 deletion
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

@@ -67,4 +84,4 @@ The ``-b`` flag adds as a regex pattern to block files you do not wish to
6784
update in PyMongo.
6885
This is primarily helpful if you are implementing a new feature in PyMongo
6986
that has spec tests already implemented, or if you are attempting to
70-
validate new spec tests in PyMongo.
87+
validate new spec tests in PyMongo.

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-

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/

doc/migrate-to-pymongo4.rst

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

0 commit comments

Comments
 (0)