Melika Kheirieh commited on
Commit
dc4d6bd
·
1 Parent(s): ccefd8e

chore(pre-commit): split auto-fix on commit vs checks on push; run mypy/pytest on push

Browse files
Files changed (1) hide show
  1. .pre-commit-config.yaml +22 -8
.pre-commit-config.yaml CHANGED
@@ -1,34 +1,48 @@
 
 
 
1
  repos:
2
- # --- Basic hygiene checks ---
3
  - repo: https://github.com/pre-commit/pre-commit-hooks
4
  rev: v6.0.0
5
  hooks:
6
- - id: check-merge-conflict
7
- - id: end-of-file-fixer
8
- - id: trailing-whitespace
 
 
9
 
10
- # --- Ruff: linting and formatting ---
11
  - repo: https://github.com/astral-sh/ruff-pre-commit
12
  rev: v0.14.3
13
  hooks:
14
  - id: ruff
15
- args: [--fix, --exit-non-zero-on-fix]
 
 
16
  - id: ruff-format
 
17
 
18
- # --- Mypy: type-checking on staged Python files ---
19
  - repo: https://github.com/pre-commit/mirrors-mypy
20
  rev: v1.18.2
21
  hooks:
22
  - id: mypy
 
 
23
  args:
 
24
  - --ignore-missing-imports
25
  - --explicit-package-bases
 
26
 
27
- # --- Run pytest via Makefile when pushing ---
28
  - repo: local
29
  hooks:
30
  - id: pytest-on-push
31
  name: pytest (pre-push)
 
 
32
  entry: make test
33
  language: system
34
  pass_filenames: false
 
1
+ # Run auto-fix hooks only on commit; run heavy checks (mypy, pytest) on push.
2
+ default_stages: [pre-commit]
3
+
4
  repos:
5
+ # --- Basic hygiene checks (auto-fix) — commit only ---
6
  - repo: https://github.com/pre-commit/pre-commit-hooks
7
  rev: v6.0.0
8
  hooks:
9
+ - id: check-merge-conflict # sanity check only
10
+ - id: end-of-file-fixer # ensures newline at EOF
11
+ stages: [pre-commit]
12
+ - id: trailing-whitespace # removes trailing spaces
13
+ stages: [pre-commit]
14
 
15
+ # --- Ruff: linting and formatting (auto-fix) — commit only ---
16
  - repo: https://github.com/astral-sh/ruff-pre-commit
17
  rev: v0.14.3
18
  hooks:
19
  - id: ruff
20
+ # Allow auto-fix; do not fail if fixes are applied.
21
+ args: [--fix]
22
+ stages: [pre-commit]
23
  - id: ruff-format
24
+ stages: [pre-commit]
25
 
26
+ # --- Mypy: type-checking push only (no edits) ---
27
  - repo: https://github.com/pre-commit/mirrors-mypy
28
  rev: v1.18.2
29
  hooks:
30
  - id: mypy
31
+ # Run on the entire repo at push time (not just changed files)
32
+ pass_filenames: false
33
  args:
34
+ - .
35
  - --ignore-missing-imports
36
  - --explicit-package-bases
37
+ stages: [pre-push]
38
 
39
+ # --- Pytest: run test suite push only (no edits) ---
40
  - repo: local
41
  hooks:
42
  - id: pytest-on-push
43
  name: pytest (pre-push)
44
+ # If Makefile is present, keep this entry; otherwise use:
45
+ # entry: bash -lc 'PYTHONPATH=$PWD pytest -q -m "not slow"'
46
  entry: make test
47
  language: system
48
  pass_filenames: false