README / .pre-commit-config.yaml
stackConsult's picture
Add pre-commit hooks for code quality and error prevention
3af8cdd verified
Raw History Blame Contribute Delete
1.34 kB
# Pre-commit hooks configuration
# Install: pip install pre-commit && pre-commit install
# Run manually: pre-commit run --all-files
repos:
# Python syntax checking
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-ast
name: Check Python AST
description: Validates Python syntax before commit
- id: check-yaml
name: Check YAML syntax
- id: check-json
name: Check JSON syntax
- id: end-of-file-fixer
name: Fix end of files
- id: trailing-whitespace
name: Trim trailing whitespace
- id: check-added-large-files
name: Check for large files
args: ['--maxkb=500']
- id: check-merge-conflict
name: Check for merge conflicts
- id: debug-statements
name: Check for debug statements
# Python code formatting
- repo: https://github.com/psf/black
rev: 23.12.1
hooks:
- id: black
name: Format with Black
language_version: python3
args: ['--line-length=100']
# Python linting with Ruff (ultra-fast)
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9
hooks:
- id: ruff
name: Lint with Ruff
args: ['--fix', '--exit-non-zero-on-fix']
- id: ruff-format
name: Format with Ruff