Repository navigation
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
215 lines (201 loc) · 6.96 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
215 lines (201 loc) · 6.96 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
# DiffBio Pre-commit Configuration
# Aligned with the avitai-org pre-commit conventions used across datarax, artifex,
# opifex, and calibrax — same anchor-based excludes, same local hook pattern, with
# DiffBio-specific architecture and complexity gates layered on top.
repos:
# TOML formatting
- repo: local
hooks:
- id: sort_pyproject
name: sort_pyproject
entry: toml-sort
language: python
args: [-i, --sort-table-keys, --sort-inline-tables, pyproject.toml]
files: ^pyproject\.toml$
additional_dependencies: ["toml-sort==0.23.1"]
# Standard pre-commit hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
exclude: &repo_non_source_exclude ^(?:memory-bank|notebooks|\.deprecated)/|^uv\.lock$
- id: end-of-file-fixer
exclude: *repo_non_source_exclude
- id: check-yaml
exclude: &repo_yaml_syntax_exclude ^(?:memory-bank|notebooks|\.deprecated)/(?:.*)|mkdocs\.yml$
- id: check-added-large-files
args: ["--maxkb=2000"]
exclude: *repo_non_source_exclude
- id: check-merge-conflict
- id: check-toml
- id: check-json
exclude: *repo_non_source_exclude
- id: debug-statements
exclude: *repo_non_source_exclude
- id: mixed-line-ending
exclude: *repo_non_source_exclude
# Python linting and formatting with auto-fix
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.8
hooks:
- id: ruff
args: [--fix, --unsafe-fixes]
exclude: *repo_non_source_exclude
types_or: [python, pyi, jupyter, toml]
- id: ruff-format
types_or: [python, pyi, jupyter, toml]
exclude: *repo_non_source_exclude
# GitHub Actions simulation - exact mirror of CI checks
- repo: local
hooks:
- id: ruff-docstring-whitespace
name: ruff-docstring-whitespace (auto-fix whitespace)
entry: ruff check --select=W291,W292,W293,F841 --fix --unsafe-fixes
language: system
types: [python]
exclude: *repo_non_source_exclude
pass_filenames: true
- id: ruff-github-actions-check
name: ruff-github-actions-check (mirrors CI)
entry: uv run ruff check --output-format=github
language: system
types: [python]
exclude: *repo_non_source_exclude
pass_filenames: false
always_run: true
- id: ruff-critical-check
name: ruff-critical-check (fast CI-critical rules only)
# F821 excluded due to false positives from jaxtyping dimension annotations
entry: uv run ruff check --select=RUF005,B904,F822,F823 --output-format=github
language: system
types: [python]
exclude: *repo_non_source_exclude
pass_filenames: false
always_run: true
# Manual-stage strict checks (run with: pre-commit run --hook-stage manual)
- repo: local
hooks:
- id: flake8-functions-names
name: flake8-functions-names (FNE)
entry: uv run flake8 --select=FNE src tests
language: system
types: [python]
stages: [manual]
pass_filenames: false
- id: flake8-wemake-wps233
name: flake8-wemake WPS233
entry: uv run flake8 --select=WPS233 src tests
language: system
types: [python]
stages: [manual]
pass_filenames: false
- id: pylint-targeted-guide-checks
name: pylint targeted guide checks
entry: >-
uv run pylint --disable=all
--enable=duplicate-code,too-many-public-methods,too-many-instance-attributes,too-few-public-methods,too-many-ancestors,inconsistent-return-statements
--reports=no --score=no src/diffbio
language: system
types: [python]
stages: [manual]
pass_filenames: false
# Type checking - reuse the project venv so pre-commit stays hermetic
- repo: local
hooks:
- id: pyright
name: pyright (project environment)
entry: uv run pyright --warnings
language: system
types_or: [python, pyi]
files: ^src/.*\.py$
pass_filenames: true
# Security scanning
- repo: https://github.com/PyCQA/bandit
rev: 1.8.6
hooks:
- id: bandit
args: ["-c", "pyproject.toml"]
exclude: &repo_non_source_and_tests_exclude ^(?:memory-bank|notebooks|\.deprecated|tests)/
additional_dependencies: ["bandit[toml]"]
log_file: /dev/null
# Documentation quality
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
exclude: &repo_non_source_tests_examples_exclude ^(?:memory-bank|notebooks|\.deprecated|tests|examples)/
additional_dependencies: ["pydocstyle[toml]"]
args: ["--config=pyproject.toml"]
# Architecture and code quality gates from SWE standards
- repo: local
hooks:
- id: lint-imports
name: lint-imports (architecture contracts)
entry: uv run lint-imports
language: system
pass_filenames: false
always_run: true
- id: radon-complexity
name: radon-complexity (cyclomatic complexity)
entry: uv run radon cc src -a -nc
language: system
pass_filenames: false
always_run: true
- id: interrogate
name: interrogate (docstring coverage)
entry: uv run interrogate src -v
language: system
pass_filenames: false
always_run: true
# Notebook quality
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.1
hooks:
- id: nbqa-ruff
exclude: *repo_non_source_exclude
args: [--fix]
# Shell script quality
- repo: local
hooks:
- id: shellcheck
name: shellcheck
entry: shellcheck
language: system
types: [shell]
exclude: *repo_non_source_exclude
args: ["-e", "SC1091"]
pass_filenames: true
always_run: false
# File length check
- repo: local
hooks:
- id: check-file-length
name: check-file-length (warn >1500, fail >2000 lines)
entry: bash
args:
- -c
- |
for file in "$@"; do
lines=$(wc -l < "$file" 2>/dev/null || echo 0)
if [ "$lines" -gt 2000 ]; then
echo "ERROR: $file has $lines lines (limit: 2000)"
exit 1
elif [ "$lines" -gt 1500 ]; then
echo "WARNING: $file has $lines lines (approaching limit of 2000)"
fi
done
- --
language: system
types: [python]
exclude: *repo_non_source_and_tests_exclude
# CI configuration - no autofix, manual testing before commits
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: false
autoupdate_branch: ""
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
autoupdate_schedule: weekly
skip: []
submodules: false