forked from Positronic-Robotics/positronic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
73 lines (70 loc) · 3.03 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
73 lines (70 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
repos:
# Ruff - linting and formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.2
hooks:
# Run the linter
- id: ruff
args: [--fix]
# Run the formatter
- id: ruff-format
# basedpyright - type-check ratchet: fails only on NEW errors.
# Existing errors are grandfathered in .basedpyright/baseline.json.
- repo: local
hooks:
- id: basedpyright
name: basedpyright type check
# Dedicated `.venv-typecheck` so the ratchet always sees the same deps
# (base + dev, --exact) regardless of which extras the contributor synced
# into their working .venv. Otherwise an extra like `hardware` resolves
# imports that dev-only CI cannot, basedpyright auto-prunes those baseline
# entries, and the shrunk baseline makes CI flag them as new errors.
entry: env UV_PROJECT_ENVIRONMENT=.venv-typecheck uv run --locked --exact --extra dev basedpyright
language: system
# Whole-project checker (pass_filenames: false), so run on every commit —
# a pyproject/baseline-only change or a module deletion can still shift the
# type-check result, and a python-only filter would skip those.
always_run: true
pass_filenames: false
# Only pre-commit can block the commit; the repo also installs commit-msg
# and post-commit hooks, where always_run would re-run the whole-project
# check pointlessly (and too late to fail the commit).
stages: [pre-commit]
- id: check-tests-location
name: tests live in per-package tests/ dirs
entry: python3 utilities/check_tests_location.py
language: system
files: '(^|/)(test_[^/]+\.py|[^/]+_test\.py)$'
stages: [pre-commit]
- id: basedpyright-baseline-ratchet
name: basedpyright baseline is a one-way ratchet
# Reads the baseline and git directly, so takes no filenames; scoped to fire only when
# the baseline changes (the only time a file's entry count can grow).
entry: python3 utilities/check_basedpyright_baseline_ratchet.py
language: system
files: '^\.basedpyright/baseline\.json$'
pass_filenames: false
stages: [pre-commit]
# General pre-commit hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
exclude: docker-compose\..+\.yml # Uses Docker Compose !override tags
- id: check-toml
- id: check-added-large-files
args: ['--maxkb=1000']
- id: check-merge-conflict
- id: mixed-line-ending
# Commit signature verification
- repo: local
hooks:
- id: commit-signature-check
name: Commit Signature Verification
entry: bash -c 'git cat-file commit HEAD | grep -q "^gpgsig " || { echo "ERROR - Commit is not signed. Do not use --no-gpg-sign"; exit 1; }'
language: system
stages: [post-commit]
always_run: true
pass_filenames: false