-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
78 lines (77 loc) · 3.79 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
78 lines (77 loc) · 3.79 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
76
77
78
repos:
- 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
# A Vega/Altair chart exported straight to SVG trips the hook's 500 KB default, because a
# plot of half-hourly data carries one path point per reading. Run the export through
# `npx svgo@4 --multipass --precision=1` before committing it — that is how
# docs/example_power_forecast.svg came down from 571 KB to 296 KB, with no visible change.
- id: check-added-large-files
- repo: local
hooks:
# Two ruff-check hooks, split on one thing: whether `--fix` is safe to run on the file.
#
# When an autofix needs a name the file does not import yet, ruff inserts the import into the
# file's *top-level* import block. In a marimo notebook that is the wrong place: marimo never
# executes module-level statements, it rebuilds the notebook from `with app.setup:` plus the
# `@app.cell` functions, so the new import is invisible to every cell and the notebook dies
# with a NameError the next time it is opened. `ruff check` then reports success, because the
# file it produced is perfectly valid Python.
#
# This is a whole class, not one rule — any fix that adds an import does it (UP017 and UP035
# today; the FURB/PERF fixes that reach for `itertools` would too) — and ruff has no per-file
# fixability setting to express it: `unfixable` is global, and `per-file-ignores` would
# silence the check as well as the fix. So the notebooks are checked but never auto-fixed,
# and a finding in one is applied by hand, into `app.setup`.
- id: ruff-check
name: ruff check (--fix)
entry: uv run ruff check --fix --force-exclude
language: system
types: [python]
# `[^/]+` cannot cross a directory separator, so this reaches the marimo apps sitting
# directly in each package and never `packages/dashboard/src/` or `packages/*/tests/`.
# Deliberately generic rather than a list of the six filenames: a seventh notebook would
# otherwise be exposed to exactly the silent breakage this exists to prevent.
exclude: &marimo_notebooks >-
^packages/(notebooks|dashboard)/[^/]+\.py$
- id: ruff-check-marimo
name: ruff check (marimo notebooks, no --fix)
entry: uv run ruff check --force-exclude
language: system
types: [python]
files: *marimo_notebooks
# The hooks above never auto-fix a notebook, but a hand-typed `uv run ruff check . --fix`
# still can, and `marimo check --fix` leaves the same breakage behind by another route. So
# every commit that touches a notebook also checks its cells bind every name they reference
# — see the script's docstring. `tests/test_marimo_notebooks.py` runs the same check in CI.
- id: check-marimo-notebooks
name: marimo notebooks (no unbound names)
entry: uv run python scripts/check_marimo_notebooks.py
language: system
types: [python]
files: *marimo_notebooks
- id: ruff-format
name: ruff format
entry: uv run ruff format --force-exclude
language: system
types: [python]
- id: ty
name: ty
entry: uv run --all-packages ty check --project .
language: system
pass_filenames: false
always_run: true
- id: pymarkdown
name: pymarkdown (markdown files)
entry: uv run pymarkdown scan
language: system
types: [markdown]
exclude: ^plans/
- id: lint-docstring-markdown
name: pymarkdown (Python docstrings)
entry: uv run python scripts/lint_docstring_markdown.py
language: system
types: [python]