-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
204 lines (180 loc) · 6.94 KB
/
.pre-commit-config.yaml
File metadata and controls
204 lines (180 loc) · 6.94 KB
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
default_language_version:
python: python3
default_install_hook_types: [pre-commit, commit-msg]
default_stages: [pre-commit]
# NB: The hooks in this file are listed in a particular order to reduce the number of times
# pre-commit has to run before getting an all-clear.
repos:
# ------------------------------------------------------------------------------------
# Automation hooks: Hooks that can alter the semantics of files
# ------------------------------------------------------------------------------------
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
# Automatically elide older Python syntax and replace with newer ones
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.4.2'
hooks:
# Run a number of Python linters in Rust. Not completely feature-parity with Python-based linters,
# but can autofix a number of issues before they run. Also wicked fast.
- id: ruff
args: [--target-version=py38, --fix, --line-length=100]
# ------------------------------------------------------------------------------------
# Formatting hooks: Hooks that alter the syntax but not semantics of files
# ------------------------------------------------------------------------------------
- repo: https://github.com/psf/black
rev: '24.4.2'
hooks:
# Blacken all Python code, except allow slightly longer line lengths
- id: black
args: ['--line-length=100', '--target-version=py38']
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
# Sort imports in all the Python code
- id: isort
args: [--profile, black, --line-length=100]
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.17
hooks:
# Format CommonMark (Markdown) files to have a consistent style.
- id: mdformat
# Currently only limited to the README
files: ^README\.md$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
# Format JSON files to have a consistent style.
- id: pretty-format-json
args: ['--autofix', '--no-ensure-ascii', '--top-keys=name,id']
# Remove trailing whitespace
- id: trailing-whitespace
exclude: &vendored |
(?x)^(
.*/[^/]+\.patch | # Patches
src/extern/valgrind/[^/]+\.h | # External Valgrind headers
tests/data/dbase/[^/]+\.d/.* | # Generated test data
tests/data/meas/[^/]+\.m/.* | # Generated test data
tests/data/struct/[^/]+\.hpcstruct | # Generated test data
)$
# All files must end in a single newline (or be perfectly empty)
- id: end-of-file-fixer
exclude: *vendored
# Remove the UTF8 BOM from the start of any files
- id: fix-byte-order-marker
# Ensure files have consistent endings. (This operates in the worktree, Git also normalizes the index)
- id: mixed-line-ending
# ------------------------------------------------------------------------------------
# Linting hooks: Hooks that do not alter files but checks that they satisfy various conditions
# ------------------------------------------------------------------------------------
- repo: meta
hooks:
# Check that hooks listed actually do something
- id: check-hooks-apply
# Check that any excludes do indeed exclude something
- id: check-useless-excludes
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
# Ensure all executable scripts have a shebang
- id: check-executables-have-shebangs
# Ensure symlinks always point to something
# - id: check-symlinks
# Warn if symlinks are ever accidentally destroyed
- id: destroyed-symlinks
# Ensure conflict markers are never committed anywhere
- id: check-merge-conflict
# Ensure files do not differ only in case (problematic on some filesystems)
- id: check-case-conflict
# Reminder to always work in a branch separate from the main two
- id: no-commit-to-branch
args: [--branch, master, --branch, develop]
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
rev: '2.7.3'
hooks:
# Run a separate checker to ensure the .editorconfig rules are being followed
- id: editorconfig-checker
alias: ec
args: [-disable-indent-size, -disable-max-line-length]
exclude: *vendored
- repo: https://github.com/python-poetry/poetry
rev: '1.8.0'
hooks:
# Ensure the pyproject.toml files are valid for Poetry
- id: poetry-check
args: [-C, lib/python/, --lock]
- repo: https://github.com/netromdk/vermin
rev: v1.6.0
hooks:
# Check that the Python code doesn't require a newer version than expected
- id: vermin
args: [--violations, -vvv]
- repo: https://github.com/jendrikseipp/vulture
rev: v2.11
hooks:
# Check that there isn't any dead Python code lying around
- id: vulture
args: ['lib/python']
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.10.0
hooks:
# Run static checks on the Python code
- id: mypy
# NB: The MyPy cache needs to be disabled (--no-incremental) to dodge
# https://github.com/python/mypy/issues/12664 which affects ruamel.yaml
args: [--scripts-are-modules, --no-incremental, --show-column-numbers, --pretty]
additional_dependencies:
- pytest >=7.3.2, <8
- ruamel.yaml >=0.17.16, <0.18
- click >=8.1.5, <9
- pyparsing >=3.0.9, <4
- Jinja2 >=3.1, <4
- repo: https://github.com/pylint-dev/pylint
rev: v3.1.0
hooks:
# Run the aggressive static Python linter
- id: pylint
additional_dependencies:
- ruamel.yaml >=0.17.32, <0.18
- pylint-pytest
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
# Find common errors in shell scripts using shellcheck
- id: shellcheck
args: ['--exclude=SC2154']
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: '0.28.2'
hooks:
# Validate the GitLab CI scripts against the schema. Doesn't catch everything but helps
- id: check-gitlab-ci
# Validate the devcontainers configurations against the schema.
- id: check-jsonschema
alias: check-devcontainer
files: '(^|/)devcontainer\.json'
args: ['--schemafile', 'https://raw.githubusercontent.com/devcontainers/spec/d424cc157e9a110f3bf67d311b46c7306d5a465d/schemas/devContainer.base.schema.json']
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
# Identify common spelling mistakes in code and comments
- id: codespell
stages: [pre-commit, commit-msg]
args: ['--config', '.codespellrc']
exclude: |
(?x)^(
lib/dtd/mathml/.*\.ent | # MathML follows LaTeX's habit of funny names for math symbols
tools/latex2man/.* | # External code
src/extern/valgrind/[^/]+\.h | # External Valgrind headers
)$
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
# Scan for secrets that should never appear in the repo itself
- id: detect-secrets
exclude: |
(?x)^(
.*\.hpcstruct | # Structfiles have lots of high-entropy strings
subprojects/[^/]+\.wrap | # Wraps almost always contain SHA256 hashes
)$