Skip to content

Commit 173dd57

Browse files
committed
ci: Add pre-commit-config
1 parent efaabd3 commit 173dd57

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.pre-commit-config.yaml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
repos:
2+
# ===============================================
3+
# Pre-commit standard hooks (general file cleanup)
4+
# ===============================================
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.6.0
7+
hooks:
8+
- id: trailing-whitespace # Removes extra whitespace at the end of lines
9+
- id: end-of-file-fixer # Ensures files end with a newline
10+
- id: check-yaml # Checks YAML file syntax
11+
- id: check-toml # Checks TOML file syntax (e.g., pyproject.toml)
12+
- id: check-added-large-files # Prevents committing large files
13+
args: ['--maxkb=500'] # Example: Limit to 500KB
14+
- id: check-merge-conflict # Checks for merge conflict strings
15+
- id: detect-private-key # Detects accidental private key commits
16+
17+
# ===============================================
18+
# Python Hooks
19+
# ===============================================
20+
# Pyupgrade for upgrading Python syntax to newer versions
21+
- repo: https://github.com/asottile/pyupgrade
22+
rev: v3.11.0
23+
hooks:
24+
- id: pyupgrade
25+
args: ["--py310-plus"] # Target Python 3.10+ syntax, matching project's target
26+
27+
# Autoflake for removing unused imports and variables
28+
- repo: https://github.com/pycqa/autoflake
29+
rev: v2.3.1
30+
hooks:
31+
- id: autoflake
32+
args: ["--in-place", "--remove-all-unused-imports"]
33+
34+
# Ruff for linting and formatting
35+
- repo: https://github.com/astral-sh/ruff-pre-commit
36+
rev: v0.4.8
37+
hooks:
38+
- id: ruff # Linter: applies auto-fixable linting rules
39+
args: [ "--fix", "--exit-zero" ] # Apply fixes, and exit with 0 even if files were modified
40+
- id: ruff-format # Formatter: similar to Black, handles consistent code style
41+
args: [] # Check formatting, but do not auto-fix during commit; fail if not formatted

0 commit comments

Comments
 (0)