-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
188 lines (166 loc) · 6.15 KB
/
.pre-commit-config.yaml
File metadata and controls
188 lines (166 loc) · 6.15 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
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3
# Global exclusions to prevent hooks from scanning unnecessary directories
exclude: ^(venv/|build/|dist/|\.git/|__pycache__/|.*\.egg-info/|\.pytest_cache/|\.mypy_cache/|\.ruff_cache/|\.uv-cache/|\.uv_cache/|htmlcov/|\.coverage|reports/|llm-agent-tools/|\.tickets/|tinyAgent/)
repos:
# Pre-commit framework hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
# Auto-generated file: models_registry.json
exclude: models_registry\.json$
- id: check-yaml
args: ['--allow-multiple-documents']
- id: check-added-large-files
args: ['--maxkb=1000']
- id: check-case-conflict
- id: check-merge-conflict
- id: check-json
- id: check-toml
- id: check-ast
- id: debug-statements
- id: mixed-line-ending
args: ['--fix=lf']
- id: check-docstring-first
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
# Python specific security checks
- repo: https://github.com/PyCQA/bandit
rev: 1.8.0
hooks:
- id: bandit
args: ['-c', 'pyproject.toml']
additional_dependencies: ['bandit[toml]']
# Ruff - Fast Python linter and formatter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.9
hooks:
- id: ruff
args: ['--fix', '--show-fixes']
- id: ruff-format # Re-enabled - ruff handles linting, ruff-format handles formatting
exclude: models_registry\.json$
# Local hooks for project-specific checks
- repo: local
hooks:
- id: mypy
name: mypy
entry: uv run mypy --ignore-missing-imports --no-strict-optional src/tunacode/
language: system
files: ^src/.*\.py$
exclude: '(conftest\.py|^tests/|^scripts/)'
pass_filenames: false
stages: [pre-push]
# UV-managed tools
- id: dead-imports
name: Check for unused imports in changed files
entry: scripts/run-dead-imports.sh
language: script
files: \.py$
stages: [pre-commit]
- id: vulture-changed
name: Check for dead code in changed files
entry: uv run vulture --min-confidence 80 scripts/utils/vulture_whitelist.py
language: system
files: ^src/.*\.py$
pass_filenames: true
exclude: ^(tests/|test_)
stages: [pre-commit]
- id: unused-constants
name: Check for unused constants
entry: uv run python scripts/check-unused-constants.py
language: system
pass_filenames: false
stages: [pre-commit]
# Check for common security issues
- id: security-check
name: Security audit
entry: bash -c 'grep -H "PRIVATE\|SECRET\|PASSWORD\|TOKEN" "$@" || exit 0' --
language: system
files: ^src/.*\.py$
# Validate no print statements in production code
- id: no-print-statements
name: Check for print statements
entry: bash -c 'grep -H "print(" "$@" | grep -v "# noqa" | grep -v "# pragma" || exit 0' --
language: system
files: ^src/.*\.py$
# Check for files longer than 600 lines (only runs when py files change)
- id: check-file-length
name: Check for files longer than 600 lines
entry: scripts/check-file-length.sh
language: script
files: \.py$
exclude: ^tests/benchmarks/bench_discover\.py$
pass_filenames: true
# Check naming conventions
- id: naming-conventions
name: Check naming conventions
entry: uv run python scripts/check-naming-conventions.py
language: system
files: ^src/.*\.py$
exclude: ^(tests/|scripts/)
# Ban defensive slop patterns in internal typed message paths
- id: defensive-slop
name: Check defensive slop patterns
entry: uv run python scripts/check-defensive-slop.py
language: system
files: ^src/.*\.py$
pass_filenames: true
stages: [pre-commit, pre-push]
# Check for duplicate code (runs on push - pylint is slow)
- id: pylint-duplicates
name: Check for duplicate code
entry: uv run pylint --disable=all --enable=R0801 --min-similarity-lines=15
language: system
files: ^src/.*\.py$
exclude: ^(tests/|scripts/|__pycache__/)
pass_filenames: true
stages: [pre-push]
# Run tests (runs on push - too slow for every commit)
- id: pytest
name: Run tests
entry: uv run pytest -x -q
language: system
pass_filenames: false
stages: [pre-push]
# Dependency layer check (runs on commit - architectural check)
# Note: Map visualization generated by GitHub Action on master pushes
- id: dependency-layers
name: Check dependency layers
entry: uv run pytest tests/test_dependency_layers.py -v
language: system
pass_filenames: false
stages: [pre-commit]
# Import sorting with isort - DISABLED (ruff handles this with extend-select = ["I"])
# - repo: https://github.com/pycqa/isort
# rev: 5.13.2
# hooks:
# - id: isort
# args: ['--profile', 'black', '--filter-files']
# Documentation linting
- repo: https://github.com/pycqa/doc8
rev: v1.1.2
hooks:
- id: doc8
args: ['--max-line-length=120']
# Markdown linting - temporarily disabled due to Node.js v23 compatibility issue
# - repo: https://github.com/igorshubovych/markdownlint-cli
# rev: v0.42.0
# hooks:
# - id: markdownlint
# args: ['--disable', 'MD013', 'MD033', 'MD041']
# Configuration for ci
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 hooks that require project-specific environment setup or modify files
skip: [vulture-changed]
submodules: false