-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
173 lines (158 loc) · 5.42 KB
/
.pre-commit-config.yaml
File metadata and controls
173 lines (158 loc) · 5.42 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
# Pre-commit configuration for VersionTracker
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3.12
repos:
# General file and formatting checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-yaml
args: [--unsafe]
- id: check-added-large-files
args: [--maxkb=1000]
- id: check-case-conflict
- id: check-merge-conflict
- id: check-json
- id: check-toml
- id: debug-statements
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: mixed-line-ending
args: [--fix=lf]
- id: pretty-format-json
args: [--autofix, --indent=2]
# Python code formatting and linting with Ruff (includes import sorting)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.0
hooks:
# Linter (includes isort functionality)
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --target-version=py312]
# Formatter
- id: ruff-format
# Type checking with mypy
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.16.1
hooks:
- id: mypy
additional_dependencies:
[
types-PyYAML,
types-tabulate,
types-termcolor,
types-requests,
types-psutil,
types-tqdm,
]
args:
[
--python-version=3.12,
--ignore-missing-imports,
--disable-error-code=import-untyped,
--disable-error-code=misc,
]
exclude: ^(tests/|docs/|benchmarks/|examples/|versiontracker/experimental/)
# Security linting with bandit
- repo: https://github.com/PyCQA/bandit
rev: 1.8.5
hooks:
- id: bandit
args:
[
--skip,
"B101,B110,B404,B602,B603,B607,B608",
--severity-level,
medium,
]
exclude: ^tests/
files: ^versiontracker/
# Documentation string checking
- repo: https://github.com/pycqa/pydocstyle
rev: 6.3.0
hooks:
- id: pydocstyle
args: [--convention=google]
exclude: ^(tests/|docs/|examples/)
# YAML formatting
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
types: [yaml]
exclude: ^(.github/workflows/|docker-compose)
# Shell script linting
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
# Markdown linting
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.45.0
hooks:
- id: markdownlint
args: [--fix]
exclude: ^(CHANGELOG.md|.*_STATUS\.md|.*_FIXES\.md|.*_IMPROVEMENTS\.md|.*_SUMMARY\.md|TESTING\.md|CODE_REVIEW_SUMMARY\.md|FINAL_BADGE_STATUS\.md|docs/.*\.md)$
# Check for secrets
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
args: [--baseline, .secrets.baseline]
exclude: ^(tests/|docs/)
# Additional Python checks
- repo: local
hooks:
# Check for TODO/FIXME comments
- id: check-todos
name: Check for TODO/FIXME comments
entry: python -c "import sys; import re; files = sys.argv[1:]; todo_pattern = re.compile(r'(TODO|FIXME|XXX|HACK)', re.IGNORECASE); found = False; [print(f'{f}:{i+1}:{line.strip()}') or setattr(sys.modules[__name__], 'found', True) for f in files for i, line in enumerate(open(f, encoding='utf-8', errors='ignore')) if todo_pattern.search(line)]; sys.exit(1 if found else 0)"
language: system
types: [python]
pass_filenames: true
# Check version consistency
- id: check-version-consistency
name: Check version consistency
entry: python
args:
- -c
- |
import sys
import re
try:
with open('versiontracker/__init__.py', 'r') as f:
content = f.read()
match = re.search(r'__version__ = [\"\'](.*?)[\"\']', content)
if not match:
print('ERROR: Could not find __version__ in versiontracker/__init__.py')
sys.exit(1)
version = match.group(1)
print(f'Found version: {version}')
# Check if version follows semantic versioning
if not re.match(r'^\d+\.\d+\.\d+(-[\w\d.-]+)?$', version):
print(f'ERROR: Version {version} does not follow semantic versioning')
sys.exit(1)
print('✅ Version format is valid')
except Exception as e:
print(f'ERROR: {e}')
sys.exit(1)
language: system
files: ^versiontracker/__init__.py$
pass_filenames: false
# Configuration
ci:
autofix_prs: true
autoupdate_commit_msg: "chore: update pre-commit hooks"
autoupdate_schedule: weekly
skip: [check-todos] # Skip TODO check in CI
# Minimum Python version for hooks
minimum_pre_commit_version: "3.0.0"
# Pre-commit hook installation:
# pip install pre-commit
# pre-commit install
# pre-commit install --hook-type commit-msg