-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
142 lines (130 loc) · 3.78 KB
/
.pre-commit-config.yaml
File metadata and controls
142 lines (130 loc) · 3.78 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
ci:
autofix_prs: false
autoupdate_schedule: weekly
repos:
# Sort pyproject.toml keys for consistency
- repo: local
hooks:
- id: sort_pyproject
name: sort pyproject.toml
entry: toml-sort
args: [--in-place, --all]
files: pyproject\.toml
language: python
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
- id: end-of-file-fixer
- id: check-yaml
exclude: mkdocs\.yml
- id: check-added-large-files
args: [--maxkb=2000]
- id: check-merge-conflict
- id: check-toml
- id: check-json
- id: debug-statements
- id: mixed-line-ending
# Ruff linter and formatter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.8
hooks:
- id: ruff
args: [--fix, --unsafe-fixes]
types_or: [python, pyi, jupyter]
- id: ruff-format
types_or: [python, pyi, jupyter]
# Local ruff checks mirroring CI
- repo: local
hooks:
- id: ruff-docstring-whitespace
name: ruff docstring whitespace autofix
entry: ruff
args: [check, --fix, "--select=W291,W292,W293,F841", src/, tests/]
language: system
types: [python]
pass_filenames: false
- id: ruff-github-actions-check
name: ruff (github actions output)
entry: uv
args: [run, ruff, check, --output-format=github]
language: system
types: [python]
pass_filenames: false
- id: ruff-critical-check
name: ruff critical checks
entry: ruff
args: [check, "--select=RUF005,B904,F821,F822,F823", src/, tests/]
language: system
types: [python]
pass_filenames: false
- 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: ^tests/
# Type checking with pyright
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.403
hooks:
- id: pyright
args: [--warnings, src]
pass_filenames: false
additional_dependencies:
- beartype>=0.14
- click>=8.0
- flax>=0.12.0
- jax>=0.4.0
- jaxlib>=0.4.0
- jaxtyping>=0.2.20
- matplotlib>=3.8
- numpy>=1.24
- psutil>=5.9.5
- pytest>=8.3
- scipy>=1.10
- types-psutil>=5.10
- typing_extensions>=4.5
- wandb>=0.18
# Security scanning
- repo: https://github.com/PyCQA/bandit
rev: "1.8.6"
hooks:
- id: bandit
args: [-c, pyproject.toml]
additional_dependencies: ["bandit[toml]"]
exclude: ^(tests|examples)/
# Docstring quality
- repo: https://github.com/pycqa/pydocstyle
rev: "6.3.0"
hooks:
- id: pydocstyle
additional_dependencies: ["pydocstyle[toml]"]
exclude: ^(tests|scripts|examples)/
# Notebook linting via nbQA
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.1
hooks:
- id: nbqa-ruff
args: [--fix]
# Shell script linting
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
args: [-e, SC1091]