Skip to content

Commit 0e8648f

Browse files
authored
ARROW-60 (cont) Add pre-commit config (#53)
1 parent 9814928 commit 0e8648f

File tree

9 files changed

+84
-7
lines changed

9 files changed

+84
-7
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+
981492824d1202580729c7084571425457e5e13c

.github/workflows/test-python.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,24 @@ concurrency:
88
group: tests-${{ github.ref }}
99
cancel-in-progress: true
1010

11-
defaults:
12-
run:
11+
defaults:
12+
run:
1313
working-directory: ./bindings/python
1414
shell: bash
1515

1616
jobs:
17+
18+
pre-commit:
19+
name: pre-commit
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v2
24+
- uses: actions/setup-python@v2
25+
- uses: pre-commit/[email protected]
26+
with:
27+
extra_args: --all-files --hook-stage=manual
28+
1729
build:
1830
# supercharge/mongodb-github-action requires containers so we don't test other platforms
1931
runs-on: ${{ matrix.os }}

.pre-commit-config.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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]
32+
33+
# We use the Python version instead of the original version which seems to require Docker
34+
# https://github.com/koalaman/shellcheck-precommit
35+
- repo: https://github.com/shellcheck-py/shellcheck-py
36+
rev: v0.8.0.1
37+
hooks:
38+
- id: shellcheck
39+
name: shellcheck
40+
args: ["--severity=warning"]
41+
42+
- repo: https://github.com/sirosen/check-jsonschema
43+
rev: 0.10.2
44+
hooks:
45+
- id: check-jsonschema
46+
name: "Check GitHub Workflows"
47+
files: ^\.github/workflows/
48+
types: [yaml]
49+
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]

bindings/python/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ docs/_build/
4040

4141
# libbson files
4242
libbson
43-
mongo-c-driver-*
43+
mongo-c-driver-*

bindings/python/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ Documentation
6767
Full documentation is available on `Read the Docs`_.
6868

6969

70-
.. _Read the Docs: https://mongo-arrow.readthedocs.io/en/latest
70+
.. _Read the Docs: https://mongo-arrow.readthedocs.io/en/latest

bindings/python/docs/source/changelog.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,3 @@ Changes in Version 0.1.0
3636
- 32-bit integer
3737
- 64-bit integer
3838
- Timestamp
39-

bindings/python/docs/source/developer/installation.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,20 @@ To run the test suite, you will need a MongoDB instance running on
6565
``localhost`` using port ``27017``. To run the entire test suite, do::
6666

6767
(pymongoarrow) $ python -m unittest discover test
68+
69+
Running Linters
70+
---------------
71+
72+
PyMongoArrow uses `pre-commit <https://pypi.org/project/pre-commit/>`_
73+
for managing linting of the codebase.
74+
``pre-commit`` performs various checks on all files in PyMongoArrow and uses tools
75+
that help follow a consistent code style within the codebase.
76+
77+
To set up ``pre-commit`` locally, run::
78+
79+
pip install pre-commit
80+
pre-commit install
81+
82+
To run ``pre-commit`` manually, run::
83+
84+
pre-commit run --all-files

bindings/python/docs/source/quickstart.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,3 @@ of formats including CSV, and HDF. For example, to write the data frame
117117
referenced by the variable ``df`` to a CSV file ``out.csv``, run::
118118

119119
df.to_csv('out.csv', index=False)
120-

bindings/python/docs/source/supported_types.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,3 @@ respectively, and '_id' that is an `ObjectId`, your schema can be defined as::
4343

4444
Unsupported data types in a schema cause a ``ValueError`` identifying the
4545
field and its data type.
46-

0 commit comments

Comments
 (0)