forked from nautechsystems/nautilus_trader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
340 lines (305 loc) · 10.7 KB
/
.pre-commit-config.yaml
File metadata and controls
340 lines (305 loc) · 10.7 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
repos:
##############################################################################
# General checks
##############################################################################
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: forbid-new-submodules
- id: end-of-file-fixer
types_or: [rust, cython, python, markdown]
- id: mixed-line-ending
- id: trailing-whitespace
- id: debug-statements
- id: detect-private-key
- id: check-added-large-files
exclude: ^crates/serialization/generated/capnp/
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-illegal-windows-names
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-xml
- id: check-yaml
- repo: https://github.com/jorisroovers/gitlint
rev: v0.19.1
hooks:
- id: gitlint
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.12.0-2
hooks:
- id: shfmt
args: ["-i", "2", "-ci", "-sr", "-ln", "bash", "-w"]
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.11.0.1
hooks:
- id: shellcheck
- repo: https://github.com/adrienverge/yamllint
rev: v1.37.1
hooks:
- id: yamllint
args: [--strict]
- repo: https://github.com/ComPWA/taplo-pre-commit
rev: v0.9.3
hooks:
- id: taplo-format
- repo: https://github.com/hadolint/hadolint
rev: v2.14.0
hooks:
- id: hadolint-docker
name: dockerfile-lint
description: Lint Dockerfiles for best practices and errors
- repo: https://github.com/crate-ci/typos
rev: v1.39.0 # v1.39.0 (reverts to v1 on updates)
hooks:
- id: typos
description: Checks for common typos
args: ["--force-exclude"]
types_or: [rust, python, cython, toml, yaml, rst, markdown]
- repo: https://github.com/codespell-project/codespell
rev: v2.4.1
hooks:
- id: codespell
description: Checks for common misspellings
types_or: [rust, python, cython, toml, yaml, rst, markdown]
- repo: https://github.com/gitleaks/gitleaks
rev: v8.29.1
hooks:
- id: gitleaks
name: gitleaks (secrets scan)
description: Detects hard-coded secrets prior to commit
args: ["--staged", "--redact"]
- repo: https://github.com/google/osv-scanner
rev: v2.3.0
hooks:
- id: osv-scanner
name: osv-scanner (dependency vulnerabilities)
description: Scans Cargo.lock and uv.lock for known vulnerabilities (defense-in-depth)
args: ["--config=osv-scanner.toml", "--lockfile=Cargo.lock", "--lockfile=uv.lock"]
##############################################################################
# GitHub Actions linting (complementary tools covering different aspects)
##############################################################################
- repo: https://github.com/rhysd/actionlint
rev: v1.7.9
hooks:
- id: actionlint
name: actionlint (syntax/structure)
description: Checks GitHub Actions workflow syntax and structural correctness
- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: v1.16.3
hooks:
- id: zizmor
name: zizmor (security)
description: Scans GitHub Actions workflows for security misconfigurations
args: ["--no-online-audits", "--min-severity", "medium"]
##############################################################################
# Custom hooks
##############################################################################
- repo: local
hooks:
- id: check-hidden-chars
name: check hidden unicode/control chars
description: Fail on hidden control or zero-width unicode characters in source
entry: .pre-commit-hooks/check_hidden_chars.sh
language: script
types_or: [rust, python, cython, toml, markdown, yaml, json, text]
files: '\.(rs|py|pyx|toml|md|yml|yaml|json|sh|dockerfile)$|Dockerfile.*'
- id: check-non-latin-text
name: check non-Latin text
description: Detect non-Latin characters (CJK, Cyrillic, Arabic, etc.) to enforce English-only
entry: .pre-commit-hooks/check_non_latin_text.sh
language: script
types: [text]
files: '\.(rs|py|pyx|md|toml|yaml|yml)$'
- id: check-toml-codegen
name: check toml-codegen
description: Ensures TOML files don't contain the 'codegen-backend' keyword
entry: .pre-commit-hooks/check_toml_codegen.sh
language: script
files: \.toml$
- id: check-todo-exclamation
name: check todo! markers
description: Prevents committing TODO! markers that indicate incomplete work
entry: .pre-commit-hooks/check_todo_exclamation.sh
language: script
types: [text]
pass_filenames: false
- id: check-copyright-year
name: check copyright year
description: Ensures copyright headers have current year
entry: .pre-commit-hooks/check_copyright_year.sh
language: script
types_or: [rust, python]
pass_filenames: false
- id: check-error-conventions
name: check error conventions
description: Enforces error variable naming conventions
entry: .pre-commit-hooks/check_error_conventions.sh
language: script
types_or: [rust, python, cython]
pass_filenames: false
##############################################################################
# Rust formatting and linting
##############################################################################
- repo: https://github.com/EmbarkStudios/cargo-deny
rev: 0.18.6
hooks:
- id: cargo-deny
name: cargo deny (dependency vulnerabilities)
args: ["--all-features", "check"]
- repo: local
hooks:
- id: check-anyhow-usage
name: check anyhow usage
description: Enforces anyhow conventions
entry: .pre-commit-hooks/check_anyhow_usage.sh
language: script
files: '\.rs$'
pass_filenames: false
- id: check-logging-macro-usage
name: check logging macro usage
description: Enforces logging macro conventions
entry: .pre-commit-hooks/check_logging_macro_usage.sh
language: script
files: '\.rs$'
pass_filenames: false
- id: check-pyo3-conventions
name: check pyo3 conventions
description: Enforces PyO3 naming conventions
entry: .pre-commit-hooks/check_pyo3_conventions.sh
language: script
files: '\.rs$'
pass_filenames: false
- id: check-testing-conventions
name: check testing conventions
description: Enforces testing standardizations and conventions
entry: .pre-commit-hooks/check_testing_conventions.sh
language: script
types_or: [rust]
pass_filenames: false
- id: fmt
name: cargo fmt
description: Format files with cargo fmt
entry: bash .pre-commit-hooks/cargo_fmt_stable.sh
language: system
args: ["--all", "--", "--check"]
files: '\.(rs|toml)$'
types: [file]
pass_filenames: false
- id: cargo-clippy
name: cargo clippy
description: Run the Clippy linter on the workspace
entry: cargo clippy
language: system
args:
[
"--workspace",
"--all-targets",
"--features",
"ffi,python,high-precision,defi",
"--profile",
"nextest", # Reduce rebuild triggers between testing and linting
"--",
"-D",
"warnings",
]
files: '\.(rs|toml)$'
types: [file]
pass_filenames: false
# TODO: Disabling for now as too slow
# - id: cargo-doc
# name: cargo doc
# description: Check documentation builds without errors or warnings
# entry:
# cargo doc --workspace --features "ffi,python,high-precision,defi"
# --profile nextest --no-deps --quiet
# language: system
# files: '\.(rs|toml)$'
# types: [file]
# pass_filenames: false
##############################################################################
# Python/Cython formatting and linting
##############################################################################
- repo: https://github.com/asottile/pyupgrade
rev: v3.21.2
hooks:
- id: pyupgrade
args: ["--py312-plus"]
- repo: https://github.com/asottile/add-trailing-comma
rev: v4.0.0
hooks:
- id: add-trailing-comma
name: add-trailing-comma
types: [python]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.6
hooks:
- id: ruff
name: ruff
args: ["--fix"]
- repo: https://github.com/pycqa/isort
rev: 7.0.0
hooks:
- id: isort
name: isort
types_or: [python, pyi, cython]
entry: "isort"
args: ["--settings-file", "pyproject.toml"]
- repo: https://github.com/PyCQA/docformatter
rev: v1.7.7
hooks:
- id: docformatter
language_version: python3.13 # Pin to 3.13 due to untokenize incompatibility with 3.14
additional_dependencies: [tomli]
args: [
"--wrap-summaries", "88",
"--wrap-descriptions", "88",
"--make-summary-multi-line",
"--pre-summary-newline",
"--blank",
"--recursive",
"--in-place",
]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.18.2
hooks:
- id: mypy
exclude: (^python/|^nautilus_trader/.*\.pyi$)
args: [
"--config", "pyproject.toml",
"--allow-incomplete-defs",
]
additional_dependencies: [
msgspec,
types-frozendict,
types-pytz,
types-redis,
types-requests,
types-toml,
]
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.9.11 # Must match uv-version file
hooks:
- id: uv-lock
files: ^python/uv\.lock$
- repo: https://github.com/kynan/nbstripout
rev: 0.8.2
hooks:
- id: nbstripout
##############################################################################
# Markdown formatting and linting
##############################################################################
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.19.1
hooks:
- id: markdownlint-cli2
name: markdownlint
entry: markdownlint-cli2
args:
- --config
- .markdownlint.jsonc
- --fix
files: "\\.md$"
exclude: '^(CLA\.md|CONTRIBUTING\.md|RELEASES\.md)$'