This repository was archived by the owner on Sep 22, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
232 lines (202 loc) · 5.67 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
232 lines (202 loc) · 5.67 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
# Pre-commit configuration for GraphBit
# A hybrid Rust/Python project with comprehensive code quality checks
default_language_version:
python: python3.11
repos:
# Pre-commit hooks for general file handling
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: ^(.*\.md|.*\.rst)$
- id: end-of-file-fixer
- id: check-yaml
args: [--unsafe]
- id: check-toml
- id: check-json
- id: check-xml
- id: check-merge-conflict
- id: check-case-conflict
- id: check-symlinks
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: fix-byte-order-marker
- id: mixed-line-ending
args: [--fix=lf]
- id: check-added-large-files
args: [--maxkb=1000]
# Python Code Formatting
- repo: https://github.com/psf/black
rev: 25.1.0
hooks:
- id: black
language_version: python3.11
args: [--line-length=200]
files: ^(tests/.*\.py|benchmarks/.*\.py|examples/.*\.py|scripts/.*\.py)$
# Python Import Sorting
- repo: https://github.com/pycqa/isort
rev: 6.0.1
hooks:
- id: isort
# args: [--profile=black, --line-length=200]
args: [--profile=black]
files: ^(tests/.*\.py|benchmarks/.*\.py|examples/.*\.py|scripts/.*\.py)$
# Python Linting
- repo: https://github.com/pycqa/flake8
rev: 7.3.0
hooks:
- id: flake8
args: [--max-line-length=200, '--extend-ignore=E203,W503']
files: ^(tests/.*\.py|benchmarks/.*\.py|examples/.*\.py|scripts/.*\.py)$
additional_dependencies:
- flake8-docstrings
- flake8-bugbear
- flake8-comprehensions
- flake8-simplify
# Python Type Checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.16.1
hooks:
- id: mypy
# args: [--ignore-missing-imports, --no-strict-optional]
args: [--config-file=.mypy.ini]
files: ^(tests/.*\.py|benchmarks/.*\.py|examples/.*\.py|scripts/.*\.py)$
additional_dependencies:
- types-requests
- types-python-dateutil
- types-PyYAML
# Python Security Checks
- repo: https://github.com/pycqa/bandit
rev: 1.8.5
hooks:
- id: bandit
args: [-r, '--skip=B101,B601']
files: ^(tests/.*\.py|benchmarks/.*\.py|examples/.*\.py|scripts/.*\.py)$
# Python Dependency Safety Check
- repo: local
hooks:
- id: safety-check
name: Safety dependency check
entry: poetry run safety check
language: system
pass_filenames: false
files: ^(pyproject\.toml|poetry\.lock)$
# Rust Formatting
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
name: Rust fmt
args: [--all, --]
# Rust Linting
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: clippy
name: Rust clippy
args: [--workspace, --all-targets, --all-features, --, -D, warnings]
# Rust Security Audit
- repo: https://github.com/cathiele/pre-commit-rust
rev: v0.1.0
hooks:
- id: cargo-audit
name: Rust security audit
# TOML Formatting and Validation
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.15.0
hooks:
- id: pretty-format-toml
args: [--autofix]
files: ^.*\.toml$
# YAML Formatting
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.15.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']
files: ^.*\.ya?ml$
# # Secret Detection
# - repo: https://github.com/Yelp/detect-secrets
# rev: v1.5.0
# hooks:
# - id: detect-secrets
# args: [--baseline, .secrets.baseline]
# Spell Checking
- repo: https://github.com/crate-ci/typos
rev: v1.28.3
hooks:
- id: typos
exclude: ^(site/|Cargo\.lock|poetry\.lock|CHANGELOG\.md)$
# Dockerfile Linting (if any Dockerfiles exist)
- repo: https://github.com/hadolint/hadolint
rev: v2.13.1-beta
hooks:
- id: hadolint-docker
files: ^.*Dockerfile.*$
# Shell Script Linting
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
files: ^.*\.(sh|bash)$
# Commit Message Linting
- repo: https://github.com/commitizen-tools/commitizen
rev: v4.8.3
hooks:
- id: commitizen
stages: [commit-msg]
# Local hooks for custom checks
- repo: local
hooks:
# Python tests (fast subset)
# - id: python-test-unit
# name: Python unit tests
# entry: python -m pytest -x --tb=short
#language: system
# files: ^tests/python_integration_tests/.*\.py$
# pass_filenames: false
# Build check for Rust
- id: rust-build-check
name: Rust build check
entry: cargo check --workspace --all-targets
language: system
files: ^(src/.*\.rs|core/src/.*\.rs|python/src/.*\.rs|Cargo\.toml|.*/Cargo\.toml)$
pass_filenames: false
# Python build check
- id: python-build-check
name: Python build check
entry: poetry check
language: system
files: ^(pyproject\.toml|poetry\.lock)$
pass_filenames: false
# Dependency vulnerability check
- id: cargo-deny
name: Cargo deny check
entry: bash -c 'if command -v cargo-deny &> /dev/null; then cargo deny check; else echo "cargo-deny not installed, skipping"; fi'
language: system
files: ^(Cargo\.toml|Cargo\.lock|.*/Cargo\.toml)$
pass_filenames: false
# +# NOTE: Ensure `.secrets.baseline` exists to prevent hook failure
# +# Run: detect-secrets scan > .secrets.baseline
# # Configuration for specific hooks
# ci:
# autoupdate_schedule: monthly
# autoupdate_commit_msg: 'chore: update pre-commit hooks'
# Exclude certain files/directories
exclude: |
(?x)^(
target/|
Cargo\.lock|
poetry\.lock|
\.git/|
\.pytest_cache/|
__pycache__/|
\.mypy_cache/|
\.venv/|
venv/|
\.env|
\.coverage|
htmlcov/|
logs/|
\.log$
)$