|
| 1 | +# Pre-commit hook configuration |
| 2 | +# Docs: https://pre-commit.com/ |
| 3 | +# |
| 4 | +# Install: |
| 5 | +# pip install pre-commit # or: poetry install --with lint |
| 6 | +# pre-commit install # register the git hook |
| 7 | +# |
| 8 | +# Run manually against all files: |
| 9 | +# pre-commit run --all-files |
| 10 | +# |
| 11 | +# Update hook revisions to latest: |
| 12 | +# pre-commit autoupdate |
| 13 | + |
| 14 | +default_language_version: |
| 15 | + python: python3.11 |
| 16 | + |
1 | 17 | repos: |
2 | | - - repo: https://github.com/ambv/black |
3 | | - # rev must match pyproject.toml |
4 | | - rev: 23.3.0 |
| 18 | + # --------------------------------------------------------------------------- |
| 19 | + # General hygiene |
| 20 | + # --------------------------------------------------------------------------- |
| 21 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 22 | + rev: v5.0.0 |
5 | 23 | hooks: |
6 | | - - id: black |
7 | | - args: ["-l", "100"] |
8 | | - - repo: https://github.com/myint/autoflake |
9 | | - # rev must match pyproject.toml |
10 | | - rev: v1.4 # rev depends on tag name in git not pip version number (thus the v prefix is required here) |
| 24 | + - id: trailing-whitespace # strip trailing whitespace |
| 25 | + - id: end-of-file-fixer # ensure files end with a newline |
| 26 | + - id: check-yaml # validate YAML syntax |
| 27 | + - id: check-toml # validate TOML syntax |
| 28 | + - id: check-json # validate JSON syntax |
| 29 | + - id: check-merge-conflict # forbid merge-conflict markers |
| 30 | + - id: check-added-large-files # warn on large committed files |
| 31 | + args: ["--maxkb=1024"] |
| 32 | + - id: debug-statements # catch leftover debugger imports |
| 33 | + - id: mixed-line-ending |
| 34 | + args: ["--fix=lf"] |
| 35 | + |
| 36 | + # --------------------------------------------------------------------------- |
| 37 | + # Ruff – fast Python linter (replaces flake8, isort, pyupgrade, …) |
| 38 | + # --------------------------------------------------------------------------- |
| 39 | + - repo: https://github.com/astral-sh/ruff-pre-commit |
| 40 | + rev: v0.15.11 |
11 | 41 | hooks: |
12 | | - - id: autoflake |
13 | | - args: |
14 | | - [ |
15 | | - "--in-place", |
16 | | - "--remove-all-unused-imports", |
17 | | - "--ignore-init-module-imports", |
18 | | - ] |
19 | | - - repo: https://github.com/PyCQA/isort |
20 | | - # rev must match pyproject.toml |
21 | | - rev: 5.12.0 |
22 | | - hooks: |
23 | | - - id: isort |
24 | | - args: ["--profile", "black", "-l", "100"] |
25 | | -# - repo: git@github.com:mdsol/git-config-checker.git |
26 | | -# rev: 0.1.1 |
27 | | -# hooks: |
28 | | -# - id: git-config-checker |
29 | | -# args: ["--checks", "emailDomain"] |
| 42 | + - id: ruff # lint + auto-fix |
| 43 | + args: ["--fix", "--exit-non-zero-on-fix"] |
| 44 | + - id: ruff-format # format (Black-compatible) |
0 commit comments