Spaces:
Running
Running
Add pre-commit hooks
Browse files- .pre-commit-config.yaml +132 -0
.pre-commit-config.yaml
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
default_language_version:
|
2 |
+
python: python3
|
3 |
+
|
4 |
+
repos:
|
5 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
6 |
+
rev: v4.4.0
|
7 |
+
hooks:
|
8 |
+
# list of supported hooks: https://pre-commit.com/hooks.html
|
9 |
+
- id: trailing-whitespace
|
10 |
+
- id: end-of-file-fixer
|
11 |
+
- id: check-docstring-first
|
12 |
+
- id: check-yaml
|
13 |
+
- id: debug-statements
|
14 |
+
- id: detect-private-key
|
15 |
+
- id: check-executables-have-shebangs
|
16 |
+
- id: check-toml
|
17 |
+
- id: check-case-conflict
|
18 |
+
|
19 |
+
# python code formatting
|
20 |
+
- repo: https://github.com/psf/black
|
21 |
+
rev: 23.3.0
|
22 |
+
hooks:
|
23 |
+
- id: black
|
24 |
+
args: [--line-length, "99"]
|
25 |
+
|
26 |
+
# python import sorting
|
27 |
+
- repo: https://github.com/PyCQA/isort
|
28 |
+
rev: 5.12.0
|
29 |
+
hooks:
|
30 |
+
- id: isort
|
31 |
+
args: ["--profile", "black", "--filter-files"]
|
32 |
+
|
33 |
+
# python upgrading syntax to newer version
|
34 |
+
- repo: https://github.com/asottile/pyupgrade
|
35 |
+
rev: v3.3.1
|
36 |
+
hooks:
|
37 |
+
- id: pyupgrade
|
38 |
+
args: [--py38-plus]
|
39 |
+
|
40 |
+
# python docstring formatting
|
41 |
+
- repo: https://github.com/myint/docformatter
|
42 |
+
rev: v1.5.1
|
43 |
+
hooks:
|
44 |
+
- id: docformatter
|
45 |
+
args: [--in-place, --wrap-summaries=99, --wrap-descriptions=99]
|
46 |
+
|
47 |
+
# python check (PEP8), programming errors and code complexity
|
48 |
+
- repo: https://github.com/PyCQA/flake8
|
49 |
+
rev: 6.0.0
|
50 |
+
hooks:
|
51 |
+
- id: flake8
|
52 |
+
args:
|
53 |
+
[
|
54 |
+
"--extend-ignore",
|
55 |
+
"E402",
|
56 |
+
"--per-file-ignores",
|
57 |
+
"__init__.py:F401",
|
58 |
+
"--exclude",
|
59 |
+
"artifacts/*,data/*,logs/*",
|
60 |
+
"--max-line-length",
|
61 |
+
"99",
|
62 |
+
]
|
63 |
+
|
64 |
+
# python security linter
|
65 |
+
- repo: https://github.com/PyCQA/bandit
|
66 |
+
rev: "1.7.5"
|
67 |
+
hooks:
|
68 |
+
- id: bandit
|
69 |
+
args: ["-s", "B101,B202"]
|
70 |
+
|
71 |
+
# python type checker
|
72 |
+
- repo: https://github.com/mattseymour/pre-commit-pytype
|
73 |
+
rev: 2022.4.26
|
74 |
+
hooks:
|
75 |
+
- id: pytype
|
76 |
+
args: ["--disable", "import-error,not-supported-yet", "-n", "auto"]
|
77 |
+
|
78 |
+
# yaml formatting
|
79 |
+
- repo: https://github.com/pre-commit/mirrors-prettier
|
80 |
+
rev: v3.0.0-alpha.6
|
81 |
+
hooks:
|
82 |
+
- id: prettier
|
83 |
+
types: [yaml]
|
84 |
+
|
85 |
+
# shell scripts linter
|
86 |
+
- repo: https://github.com/shellcheck-py/shellcheck-py
|
87 |
+
rev: v0.9.0.2
|
88 |
+
hooks:
|
89 |
+
- id: shellcheck
|
90 |
+
|
91 |
+
# md formatting
|
92 |
+
- repo: https://github.com/executablebooks/mdformat
|
93 |
+
rev: 0.7.16
|
94 |
+
hooks:
|
95 |
+
- id: mdformat
|
96 |
+
args: ["--number"]
|
97 |
+
additional_dependencies:
|
98 |
+
- mdformat-gfm
|
99 |
+
- mdformat-tables
|
100 |
+
- mdformat_frontmatter
|
101 |
+
# - mdformat-toc
|
102 |
+
# - mdformat-black
|
103 |
+
|
104 |
+
# word spelling linter
|
105 |
+
- repo: https://github.com/codespell-project/codespell
|
106 |
+
rev: v2.2.4
|
107 |
+
hooks:
|
108 |
+
- id: codespell
|
109 |
+
args:
|
110 |
+
- --skip=artifacts/**,data/**,logs/**,*.ipynb,*.bib,*.js
|
111 |
+
- --ignore-words-list=bu
|
112 |
+
|
113 |
+
# jupyter notebook cell output clearing
|
114 |
+
- repo: https://github.com/kynan/nbstripout
|
115 |
+
rev: 0.6.1
|
116 |
+
hooks:
|
117 |
+
- id: nbstripout
|
118 |
+
|
119 |
+
# jupyter notebook linting
|
120 |
+
- repo: https://github.com/nbQA-dev/nbQA
|
121 |
+
rev: 1.7.0
|
122 |
+
hooks:
|
123 |
+
- id: nbqa-black
|
124 |
+
args: ["--line-length=99"]
|
125 |
+
- id: nbqa-isort
|
126 |
+
args: ["--profile=black"]
|
127 |
+
- id: nbqa-flake8
|
128 |
+
args:
|
129 |
+
[
|
130 |
+
"--extend-ignore=E203,E402,E501,F401,F841",
|
131 |
+
"--exclude=artifacts/*,data/*,logs/*",
|
132 |
+
]
|