-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
267 lines (238 loc) · 8.61 KB
/
.pre-commit-config.yaml
File metadata and controls
267 lines (238 loc) · 8.61 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
# Pre-commit Configuration for MLOps Ecosystem
# See https://pre-commit.com for more information
default_language_version:
python: python3.11
repos:
# ============================================================================
# General Pre-commit Hooks
# ============================================================================
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
# File checks
- id: check-added-large-files
args: ['--maxkb=1000']
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: destroyed-symlinks
# Content checks
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: check-json
- id: check-merge-conflict
- id: check-toml
- id: check-xml
- id: check-yaml
args: ['--allow-multiple-documents']
# Git checks
- id: detect-aws-credentials
args: ['--allow-missing-credentials']
- id: detect-private-key
# File modifications
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
args: ['--fix=lf']
- id: trailing-whitespace
args: ['--markdown-linebreak-ext=md']
# Python specific
- id: debug-statements
- id: fix-encoding-pragma
args: ['--remove']
- id: name-tests-test
args: ['--pytest-test-first']
# ============================================================================
# Ruff - Fast Python Linter & Formatter
# ============================================================================
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
hooks:
# Run the linter
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
types_or: [python, pyi, jupyter]
# Run the formatter
- id: ruff-format
types_or: [python, pyi, jupyter]
# ============================================================================
# Black - The Uncompromising Code Formatter
# ============================================================================
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
language_version: python3.11
args: ['--line-length=100']
- id: black-jupyter
language_version: python3.11
args: ['--line-length=100']
# ============================================================================
# isort - Import Sorting
# ============================================================================
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
args: ['--profile', 'black', '--line-length', '100']
# ============================================================================
# MyPy - Static Type Checker
# ============================================================================
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
additional_dependencies:
- types-requests
- types-PyYAML
- types-toml
- pydantic
args: [--strict, --ignore-missing-imports]
exclude: ^(tests/|examples/)
# ============================================================================
# Security & Safety Checks
# ============================================================================
- repo: https://github.com/PyCQA/bandit
rev: 1.7.6
hooks:
- id: bandit
args: ['-c', 'pyproject.toml']
additional_dependencies: ['bandit[toml]']
exclude: ^tests/
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.4.30
hooks:
- id: uv-lock
name: uv lock check
stages: [commit]
- repo: local
hooks:
- id: pytest-check
name: pytest
entry: pytest
language: system
pass_filenames: false
always_run: true
args: ['-v', '--tb=short', '--maxfail=1']
stages: [push]
- id: pytest-cov-check
name: pytest-cov
entry: pytest
language: system
pass_filenames: false
always_run: true
args: ['--cov=src/mlops', '--cov-fail-under=80', '-q']
stages: [push]
# ============================================================================
# Documentation
# ============================================================================
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
args: ['--convention=google']
exclude: ^(tests/|examples/)
additional_dependencies: [tomli]
# ============================================================================
# Markdown & Documentation Linting
# ============================================================================
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.38.0
hooks:
- id: markdownlint
args: ['--fix']
# ============================================================================
# YAML Formatting
# ============================================================================
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.11.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2']
# ============================================================================
# Dockerfile Linting
# ============================================================================
- repo: https://github.com/hadolint/hadolint
rev: v2.12.0
hooks:
- id: hadolint-docker
# ============================================================================
# Shell Script Checks
# ============================================================================
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.9.0.6
hooks:
- id: shellcheck
# ============================================================================
# Jupyter Notebook Cleanup
# ============================================================================
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
hooks:
- id: nbstripout
args: ['--extra-keys', 'metadata.kernelspec metadata.language_info']
# ============================================================================
# Requirements.txt Sorting
# ============================================================================
- repo: https://github.com/pre-commit/mirrors-pip-tools
rev: v7.3.0
hooks:
- id: pip-compile
name: pip-compile requirements.in
args: [requirements.in, --output-file, requirements.txt]
files: ^requirements\.(in|txt)$
# ============================================================================
# Additional Python Checks
# ============================================================================
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args: ['--max-line-length=100', '--extend-ignore=E203,E266,E501,W503']
additional_dependencies:
- flake8-docstrings
- flake8-bugbear
- flake8-comprehensions
- flake8-simplify
# ============================================================================
# Commit Message Linting
# ============================================================================
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.13.0
hooks:
- id: commitizen
stages: [commit-msg]
# ============================================================================
# Secret Detection
# ============================================================================
- repo: https://github.com/Yelp/detect-secrets
rev: v1.4.0
hooks:
- id: detect-secrets
args: ['--baseline', '.secrets.baseline']
exclude: |
(?x)^(
\.env\.example|
poetry\.lock|
package-lock\.json
)$
# ============================================================================
# CI Configuration
# ============================================================================
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: [mypy, safety, hadolint-docker]
submodules: false