Skip to content

Commit bf96c4a

Browse files
committed
Add stages and split ruff hooks
Introduce default_stages and explicitly assign stages to hooks, marking safe checks as pre-commit/manual and file-modifying hooks as pre-commit-only. Add check-merge-conflict, set name-tests-test args, and ensure end-of-file-fixer/trailing-whitespace run only in pre-commit. Bump pyproject-fmt to v2.21.1 and update ruff pre-commit to v0.15.12, replacing the previous ruff entries with a clear split: local autofix/format hooks (pre-commit) and CI check-only variants (manual) with appropriate args. Remove the napari-plugin-checks entry and reorganize hooks for clearer local vs CI behavior.
1 parent 1496b25 commit bf96c4a

1 file changed

Lines changed: 47 additions & 19 deletions

File tree

.pre-commit-config.yaml

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,64 @@
1+
default_stages: [pre-commit]
2+
13
repos:
24
- repo: https://github.com/pre-commit/pre-commit-hooks
35
rev: v6.0.0
46
hooks:
7+
# These are safe to run in both local & CI (they don't require "fix vs check" split)
58
- id: check-added-large-files
9+
stages: [pre-commit, manual]
610
- id: check-yaml
11+
stages: [pre-commit, manual]
712
- id: check-toml
8-
- id: end-of-file-fixer
13+
stages: [pre-commit, manual]
14+
- id: check-merge-conflict
15+
stages: [pre-commit, manual]
916
- id: name-tests-test
17+
stages: [pre-commit, manual]
18+
args: ["--pytest-test-first"]
19+
20+
# These modify files. Run locally only (pre-commit stage).
21+
- id: end-of-file-fixer
22+
stages: [pre-commit]
1023
- id: trailing-whitespace
11-
- repo: https://github.com/astral-sh/ruff-pre-commit
12-
rev: v0.15.4
13-
hooks:
14-
# Run the formatter.
15-
- id: ruff-format
16-
# Run the linter.
17-
- id: ruff-check
18-
args: [--fix,--unsafe-fixes]
24+
stages: [pre-commit]
25+
1926
- repo: https://github.com/tox-dev/pyproject-fmt
20-
rev: v2.16.2
27+
rev: v2.21.1
2128
hooks:
2229
- id: pyproject-fmt
30+
stages: [pre-commit] # modifies -> local only
31+
2332
- repo: https://github.com/abravalheri/validate-pyproject
2433
rev: v0.25
2534
hooks:
2635
- id: validate-pyproject
27-
- repo: https://github.com/tlambert03/napari-plugin-checks
28-
rev: v0.3.0
36+
stages: [pre-commit, manual]
37+
38+
- repo: https://github.com/astral-sh/ruff-pre-commit
39+
rev: v0.15.12
2940
hooks:
30-
- id: napari-plugin-checks
31-
# https://mypy.readthedocs.io/en/stable/introduction.html
32-
# you may wish to add this as well!
33-
# - repo: https://github.com/pre-commit/mirrors-mypy
34-
# rev: v0.910-1
35-
# hooks:
36-
# - id: mypy
41+
# --------------------------
42+
# LOCAL AUTOFIX (developers)
43+
# --------------------------
44+
- id: ruff-check
45+
name: ruff-check (fix)
46+
args: [--fix, --unsafe-fixes]
47+
stages: [pre-commit]
48+
49+
- id: ruff-format
50+
name: ruff-format (write)
51+
stages: [pre-commit]
52+
53+
# --------------------------
54+
# CI CHECK-ONLY (no writes)
55+
# --------------------------
56+
- id: ruff-check
57+
name: ruff-check (ci)
58+
args: [--output-format=github]
59+
stages: [manual]
60+
61+
- id: ruff-format
62+
name: ruff-format (ci)
63+
args: [--check, --diff]
64+
stages: [manual]

0 commit comments

Comments
 (0)