-
Notifications
You must be signed in to change notification settings - Fork 0
/
.pre-commit-config.yaml
205 lines (184 loc) · 5.63 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# Configuration-file for pre-commit
# References:
# - Official docs: https://pre-commit.com
# - for more hooks: https://pre-commit.com/hooks.html
#
# To avoid duplication, we try to configure the tools in pyproject.toml as much as possible.
# we call the executables via "poetry run <executable>"
#
# Usage:
# > pre-commit install
# > pre-commit install hooks -f
# > pre-commit autoupdate
# > pre-commit run --all-files
repos:
- repo: local
hooks:
# docs: https://black.readthedocs.io/en/stable/integrations/source_version_control.html
- id: black
name: Black
entry: poetry run black
args: ["--config=pyproject.toml"]
# "--check", # don't write the files back, just return the status.
language: system # use executable found on path
require_serial: true
types: [python] # check only specific filetypes
# docs: https://flake8.pycqa.org/en/latest/user/using-hooks.html
# - repo: local
# hooks:
# - id: flake8
# name: Flake8
# entry: poetry run flake8
# language: system
# require_serial: true
# types: [python]
# docs: https://pycqa.github.io/isort/docs/configuration/pre-commit.html
- repo: local
hooks:
- id: isort
name: Isort
entry: poetry run isort
args: ["--settings-path=pyproject.toml"] # "--filter-files"
language: system
require_serial: true
types: [python] # pyi? cython?
- repo: local
hooks:
- id: ruff
name: Ruff
entry: poetry run ruff
args: [--fix, --show-fixes]
# args: [--fix, --exit-non-zero-on-fix]
language: system
types: [python]
# exclude: ^.venv/
# - repo: local
# hooks:
# - id: mypy
# name: Mypy
# entry: poetry run mypy
# language: system
# types: [python]
# # files: ^src/$
# verbose: true # print the number of files as a sanity-check
# - repo: local
# hooks:
# - id: bandit
# name: Bandit
# entry: poetry run bandit
# language: system
# types: [python]
# # see https://github.com/PyCQA/bandit/issues/318
# args: ["--configfile pyproject.toml", "--baseline etc/bandit-baseline.json"]
- repo: local
hooks:
- id: poetry-check
name: Poetry check
description: run poetry check to validate config
entry: poetry check
language: python
language_version: python3
pass_filenames: false
files: ^pyproject.toml$
- repo: local
hooks:
- id: poetry-lock-check
name: Check poetry.lock is up-to-date
description: run poetry lock --check to check lock-file is in sync
entry: poetry lock --check
language: python
# language_version: python3
pass_filenames: false
files: ^pyproject.toml$
# - id: poetry-lock
# name: poetry-lock
# description: run poetry lock to update lock file
# entry: poetry lock
# language: python
# language_version: python3
# pass_filenames: false
# The following are all pre-commit-hooks
# docs: https://github.com/pre-commit/pre-commit-hooks
- repo: local
hooks:
- id: debug-statements
name: Check debug statements
entry: poetry run debug-statement-hook
language: system
types: [python]
#- repo: local
# hooks:
# - id: check-case-conflict
# name: Check for files with names that would conflict on a case-insensitive filesystem like MacOS HFS+ or Windows FAT.
# entry: poetry run check-case-conflict
# language: system
# types: [text]
- repo: local
hooks:
- id: check-toml
name: Check TOML-syntax
entry: poetry run check-toml
language: system
types: [toml]
- repo: local
hooks:
- id: check-xml
name: Check XML-syntax
entry: poetry run check-xml
language: system
types: [xml]
#- repo: local
# hooks:
# - id: check-yaml
# name: Check YAML-syntax
# entry: poetry run check-yaml
# language: system
# types: [yaml]
# # exclude: "logging.yaml, tests/logging_*.yaml"
# exclude: "tests/logging_invalid_yaml.yaml"
- repo: local
hooks:
- id: check-merge-conflict
name: Check for files that contain merge conflict strings
entry: poetry run check-merge-conflict
language: system
types: [text]
args: ["--assume-in-merge"] # Allow running this hook when there is no ongoing merge operation
- repo: local
hooks:
- id: end-of-file-fixer
name: Fix end of file
entry: poetry run end-of-file-fixer
language: system
stages: [commit, push, manual]
types: [python] # text too broad?
- repo: local
hooks:
- id: fix-encoding-pragma
name: Fix encoding pragma
entry: poetry run fix-encoding-pragma --remove
language: system
types: [python]
- repo: local
hooks:
- id: mixed-line-ending
name: Fix mixed line-endings
entry: poetry run mixed-line-ending
language: system
types: [text]
- repo: local
hooks:
- id: trailing-whitespace
name: Fix trailing whitespace
entry: poetry run trailing-whitespace-fixer
language: system
stages: [commit, push, manual]
types: [text]
#- repo: local
# hooks:
# - id: name-tests-test
# name: name-tests-test
# entry: poetry run name-tests-test
# language: system
# types: [python]
# args: ["tests --pytest-test-first"]