Skip to content

Commit 43b51c7

Browse files
committed
feat: add pre-commit
1 parent ac0afcc commit 43b51c7

File tree

7 files changed

+54
-9
lines changed

7 files changed

+54
-9
lines changed

.github/setup/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ runs:
2323
path: ~/.cache/pip
2424
key: ${{ runner.os }}-pip-${{ inputs.pip-cache-hash }}
2525
restore-keys: ${{ runner.os }}-pip-
26+
- name: Set up pre-commit cache
27+
uses: actions/cache@v2
28+
with:
29+
path: ~/.cache/pre-commit
30+
key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml' )}}
31+
restore-keys: ${{ runner.os }}-pre-commit-
2632
- name: Set up Conda with Python ${{ inputs.python-version }}
2733
uses: conda-incubator/setup-miniconda@v2
2834
with:

.isort.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[settings]
2+
profile = black

.pre-commit-config.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Configuration file for pre-commit (https://pre-commit.com/).
2+
# Please run `pre-commit run --all-files` when adding or changing entries.
3+
4+
repos:
5+
- repo: https://github.com/psf/black
6+
rev: 22.3.0
7+
hooks:
8+
- id: black
9+
- repo: https://github.com/codespell-project/codespell
10+
rev: v2.1.0
11+
hooks:
12+
- id: codespell
13+
args: [--ignore-words=.codespellignore]
14+
types_or: [jupyter, markdown, python, shell]
15+
- repo: https://github.com/PyCQA/doc8
16+
rev: 0.11.1
17+
hooks:
18+
- id: doc8
19+
- repo: https://github.com/PyCQA/flake8
20+
rev: 4.0.1
21+
hooks:
22+
- id: flake8
23+
- repo: https://github.com/pre-commit/mirrors-mypy
24+
rev: v0.942
25+
hooks:
26+
- id: mypy
27+
# TODO lint test and scripts too
28+
files: "^src/.*\\.py$"
29+
args:
30+
- --ignore-missing-imports
31+
- --explicit-package-bases
32+
additional_dependencies:
33+
- click != 8.1.0
34+
- numpy
35+
- pyproj
36+
- pystac
37+
- types-requests
38+
- repo: https://github.com/pycqa/isort
39+
rev: 5.10.1
40+
hooks:
41+
- id: isort
42+
name: isort (python)

docker/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ RUN conda install -c conda-forge pandoc && conda clean -af
3131
COPY requirements-dev.txt ./
3232
RUN pip install -r requirements-dev.txt
3333
COPY . ./
34+
RUN git init
3435
RUN pip install -e .[all]
3536

3637

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ lxml-stubs
88
mypy
99
nbsphinx
1010
packaging
11+
pre-commit
1112
pylint
1213
pytest
1314
pytest-cov

scripts/format

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ Format code with black
1313
"
1414
}
1515

16-
DIRS_TO_CHECK=("src" "tests")
17-
1816
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
1917
if [ "${1:-}" = "--help" ]; then
2018
usage
2119
else
2220
# Code formatting
23-
black ${DIRS_TO_CHECK[@]}
21+
pre-commit run black --all-files
2422
fi
2523
fi

scripts/lint

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
1919
if [ "${1:-}" = "--help" ]; then
2020
usage
2121
else
22-
# Code formatting
23-
scripts/format
24-
# Lint
25-
flake8 ${DIRS_TO_CHECK[@]}
26-
# Type checking
27-
mypy --install-types --non-interactive src
22+
pre-commit run --all-files
2823
fi
2924
fi

0 commit comments

Comments
 (0)