stackConsult commited on
Commit
3af8cdd
·
verified ·
1 Parent(s): 1499f9c

Add pre-commit hooks for code quality and error prevention

Browse files

Includes:
- check-ast: Validates Python syntax before commit
- Ruff: Ultra-fast linting and formatting
- Black: Code formatting
- YAML/JSON syntax checking
- Debug statement detection
- Merge conflict detection

To use:
1. pip install pre-commit
2. pre-commit install
3. Commits will now automatically check code quality

Files changed (1) hide show
  1. .pre-commit-config.yaml +46 -0
.pre-commit-config.yaml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Pre-commit hooks configuration
2
+ # Install: pip install pre-commit && pre-commit install
3
+ # Run manually: pre-commit run --all-files
4
+
5
+ repos:
6
+ # Python syntax checking
7
+ - repo: https://github.com/pre-commit/pre-commit-hooks
8
+ rev: v4.5.0
9
+ hooks:
10
+ - id: check-ast
11
+ name: Check Python AST
12
+ description: Validates Python syntax before commit
13
+ - id: check-yaml
14
+ name: Check YAML syntax
15
+ - id: check-json
16
+ name: Check JSON syntax
17
+ - id: end-of-file-fixer
18
+ name: Fix end of files
19
+ - id: trailing-whitespace
20
+ name: Trim trailing whitespace
21
+ - id: check-added-large-files
22
+ name: Check for large files
23
+ args: ['--maxkb=500']
24
+ - id: check-merge-conflict
25
+ name: Check for merge conflicts
26
+ - id: debug-statements
27
+ name: Check for debug statements
28
+
29
+ # Python code formatting
30
+ - repo: https://github.com/psf/black
31
+ rev: 23.12.1
32
+ hooks:
33
+ - id: black
34
+ name: Format with Black
35
+ language_version: python3
36
+ args: ['--line-length=100']
37
+
38
+ # Python linting with Ruff (ultra-fast)
39
+ - repo: https://github.com/astral-sh/ruff-pre-commit
40
+ rev: v0.1.9
41
+ hooks:
42
+ - id: ruff
43
+ name: Lint with Ruff
44
+ args: ['--fix', '--exit-non-zero-on-fix']
45
+ - id: ruff-format
46
+ name: Format with Ruff