-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
195 lines (173 loc) · 6.5 KB
/
.pre-commit-config.yaml
File metadata and controls
195 lines (173 loc) · 6.5 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
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.11
repos:
# ============================================================================
# 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
# Git checks
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: forbid-new-submodules
- id: no-commit-to-branch
args: ['--branch', 'main', '--branch', 'master']
# Content checks
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
- id: debug-statements
- id: detect-private-key
- id: fix-byte-order-marker
# File format checks
- id: check-json
- id: check-toml
- id: check-yaml
args: ['--safe']
- id: check-xml
# Whitespace and formatting
- id: end-of-file-fixer
- id: mixed-line-ending
args: ['--fix=lf']
- id: trailing-whitespace
args: ['--markdown-linebreak-ext=md']
# Python specific
- id: name-tests-test
args: ['--pytest-test-first']
- id: requirements-txt-fixer
# ============================================================================
# RUFF - Ultra-fast Python linter (replaces flake8, isort, and more)
# ============================================================================
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.4
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 Python code formatter
# ============================================================================
- repo: https://github.com/psf/black
rev: 24.3.0
hooks:
- id: black
language_version: python3.11
args: ['--config', 'pyproject.toml']
- id: black-jupyter
language_version: python3.11
# ============================================================================
# MYPY - Static type checker
# ============================================================================
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.9.0
hooks:
- id: mypy
additional_dependencies:
- pydantic>=2.6.0
- typer>=0.12.0
- rich>=13.7.0
- httpx>=0.27.0
args: [--config-file=pyproject.toml]
pass_filenames: false
# ============================================================================
# PYUPGRADE - Automatically upgrade syntax for newer versions of Python
# ============================================================================
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py39-plus]
# ============================================================================
# PRETTIER - Multi-language formatter
# ============================================================================
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types_or: [yaml, markdown, json]
exclude: ^(\.github/|docs/)
# ============================================================================
# MARKDOWN - Markdown linting
# ============================================================================
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
hooks:
- id: markdownlint
args: ['--fix']
exclude: ^(\.github/|CHANGELOG\.md)
# ============================================================================
# SHELLCHECK - Shell script linting
# ============================================================================
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
# ============================================================================
# BANDIT - Security linting
# ============================================================================
- repo: https://github.com/PyCQA/bandit
rev: 1.7.8
hooks:
- id: bandit
args: ['-c', 'pyproject.toml', '-ll']
additional_dependencies: ['bandit[toml]']
exclude: ^tests/
# ============================================================================
# PYTEST - Fast fail tests
# ============================================================================
- repo: local
hooks:
- id: pytest-fast
name: pytest-fast
entry: pytest
language: system
types: [python]
args: ["-x", "--tb=short", "--no-cov"]
pass_filenames: false
always_run: true
# ============================================================================
# POETRY - Check pyproject.toml validity
# ============================================================================
- repo: https://github.com/python-poetry/poetry
rev: 1.8.0
hooks:
- id: poetry-check
files: pyproject.toml
pass_filenames: false
# ============================================================================
# CODESPELL - Check for common misspellings
# ============================================================================
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
args: ['--ignore-words-list', 'crate,nd,sav,hist']
exclude: ^(\.git/|\.mypy_cache/|\.pytest_cache/|\.ruff_cache/)
# ============================================================================
# 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: []
submodules: false