Repository navigation
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
75 lines (72 loc) · 2.93 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
75 lines (72 loc) · 2.93 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
74
75
# `language: unsupported` (the pre-commit 4.4 name for `system`) runs a command
# from the environment pre-commit was started in.
minimum_pre_commit_version: "4.4.0"
repos:
# Pinned to a commit rather than a tag, which can be moved; the `# frozen:`
# comment names the release, and Dependabot updates both.
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-json
- id: check-toml
- id: check-yaml
- id: check-xml
- id: check-merge-conflict
- id: mixed-line-ending
args: [--fix=lf]
# ruff, mypy and typos run from the project environment, so the versions in
# uv.lock (the `dev` dependency group) are the only ones there are, and mypy
# sees the SDK's real dependencies. `uv run --locked` first syncs .venv to
# uv.lock (default groups, so the tools are always installed there and a copy
# elsewhere on PATH is never picked up) and fails if uv.lock is stale.
- repo: local
hooks:
- id: ruff-check
name: ruff check
entry: uv run --locked ruff check --fix
language: unsupported
# pyproject.toml too: ruff validates its [project] table (RUF200).
files: (\.pyi?|(^|/)pyproject\.toml)$
require_serial: true
- id: ruff-format
name: ruff format
entry: uv run --locked ruff format
language: unsupported
types_or: [python, pyi]
require_serial: true
- id: mypy
name: mypy
# No file names: mypy checks the `files` set in pyproject.toml as a whole,
# which is what makes cross-module errors visible.
entry: uv run --locked mypy
language: unsupported
# pyproject.toml and uv.lock too: they hold mypy's config and the
# dependency versions it checks against.
files: (\.pyi?|^pyproject\.toml|^uv\.lock)$
pass_filenames: false
require_serial: true
- id: typos
name: typos
entry: uv run --locked typos --force-exclude
language: unsupported
types: [text]
require_serial: true
# Fails when pyproject.toml and uv.lock disagree; run `uv lock` to fix. It runs
# the uv on PATH rather than installing its own, so there is no second uv
# version to keep in step with the dev group's `uv` pin. Under `uv run` (as in
# CI) that is the pinned uv from .venv/bin. --check never writes, so a local uv
# too old to read [tool.uv] fails here instead of re-locking with other settings.
- repo: local
hooks:
- id: uv-lock
name: uv lock --check
entry: uv lock --check
language: unsupported
files: ^(uv\.lock|pyproject\.toml|uv\.toml)$
pass_filenames: false