|
| 1 | +--- |
| 2 | +repos: |
| 3 | + # =============================================== |
| 4 | + # Pre-commit standard hooks (general file cleanup) |
| 5 | + # =============================================== |
| 6 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 7 | + rev: v4.6.0 |
| 8 | + hooks: |
| 9 | + - id: trailing-whitespace # Removes extra whitespace at the end of lines |
| 10 | + - id: end-of-file-fixer # Ensures files end with a newline |
| 11 | + - id: check-yaml # Checks YAML file syntax (before formatting) |
| 12 | + - id: check-toml # Checks TOML file syntax (before formatting) |
| 13 | + - id: check-added-large-files # Prevents committing large files |
| 14 | + args: [--maxkb=500] # Example: Limit to 500KB |
| 15 | + - id: check-merge-conflict # Checks for merge conflict strings |
| 16 | + - id: detect-private-key # Detects accidental private key commits |
| 17 | + |
| 18 | + # Formatter and linter for TOML files |
| 19 | + - repo: https://github.com/ComPWA/taplo-pre-commit |
| 20 | + rev: v0.9.3 |
| 21 | + hooks: |
| 22 | + - id: taplo-format |
| 23 | + - id: taplo-lint |
| 24 | + |
| 25 | + # YAML files |
| 26 | + - repo: https://github.com/lyz-code/yamlfix |
| 27 | + rev: 1.16.1 |
| 28 | + hooks: |
| 29 | + - id: yamlfix |
| 30 | + |
| 31 | + # =============================================== |
| 32 | + # Python Hooks |
| 33 | + # =============================================== |
| 34 | + # no_implicit_optional for ensuring explicit Optional types |
| 35 | + - repo: https://github.com/hauntsaninja/no_implicit_optional |
| 36 | + rev: '1.4' |
| 37 | + hooks: |
| 38 | + - id: no_implicit_optional |
| 39 | + args: [--use-union-or] |
| 40 | + |
| 41 | + # Pyupgrade for upgrading Python syntax to newer versions |
| 42 | + - repo: https://github.com/asottile/pyupgrade |
| 43 | + rev: v3.20.0 |
| 44 | + hooks: |
| 45 | + - id: pyupgrade |
| 46 | + args: [--py310-plus] # Target Python 3.10+ syntax, matching project's target |
| 47 | + |
| 48 | + # Autoflake for removing unused imports and variables |
| 49 | + - repo: https://github.com/pycqa/autoflake |
| 50 | + rev: v2.3.1 |
| 51 | + hooks: |
| 52 | + - id: autoflake |
| 53 | + args: [--in-place, --remove-all-unused-imports] |
| 54 | + |
| 55 | + # Ruff for linting and formatting |
| 56 | + - repo: https://github.com/astral-sh/ruff-pre-commit |
| 57 | + rev: v0.12.0 |
| 58 | + hooks: |
| 59 | + - id: ruff # Linter: applies auto-fixable linting rules |
| 60 | + args: [--fix, --exit-zero] # Apply fixes, and exit with 0 even if files were modified |
| 61 | + - id: ruff-format # Formatter: similar to Black, handles consistent code style |
| 62 | + args: [] # Check formatting, but do not auto-fix during commit; fail if not formatted |
0 commit comments