-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.pre-commit-config.yaml
75 lines (73 loc) · 2.34 KB
/
.pre-commit-config.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Install the pre-commit hooks below with
# 'pre-commit install'
# Run the hooks on all files with
# 'pre-commit run --all'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
# See: https://pre-commit.com/hooks.html
hooks:
- id: trailing-whitespace
types: [python]
exclude: ^notebooks($|/.*) # Avoids Jupytext sync problems
- id: check-case-conflict
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-yaml
- id: check-added-large-files
args: ['--maxkb=5000']
- id: end-of-file-fixer
- id: mixed-line-ending
# add black
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3
exclude: ^notebooks($|/.*)
# args: [--line-length 79]
# add isort
# TODO: does not work with black
# - repo: https://github.com/pycqa/isort
# rev: 5.12.0
# hooks:
# - id: isort
# name: isort
# exclude: ^notebooks($|/.*)
# Run flake8. Give warnings, but do not reject commits
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
exclude: ^notebooks($|/.*)
additional_dependencies: [flake8-bugbear, flake8-print]
# Enforce that notebooks outputs are cleared
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
- id: nbstripout
# notebook checks
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.7.0
hooks:
- id: nbqa-black
args: [--nbqa-mutate, --nbqa-dont-skip-bad-cells]
additional_dependencies: [black==22.3.0]
- id: nbqa-isort
args: [--nbqa-mutate, --nbqa-dont-skip-bad-cells]
additional_dependencies: [isort==5.6.4]
- id: nbqa-flake8
args: [--nbqa-dont-skip-bad-cells, "--extend-ignore=E402,E203"]
additional_dependencies: [flake8==3.8.3]
# Synchronize notebooks and paired script versions
- repo: https://github.com/mwouts/jupytext
rev: v1.14.1
hooks:
- id: jupytext
name: jupytext
description: Runs jupytext on all notebooks and paired files
language: python
entry: jupytext --pre-commit-mode --set-formats "ipynb,py:percent"
require_serial: true
types_or: [jupyter, python]
files: ^notebooks($|/.*) # Only apply this under notebooks/