Skip to content
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ repos:
- id: no-commit-to-branch
args: ["--branch", "main", "--pattern", "^versions/.*"]
always_run: true
# Restrict to pre-commit so a push (e.g. a release tag) isn't mistaken for a commit.
stages: [pre-commit]
- id: trailing-whitespace

- repo: https://github.com/pre-commit/pygrep-hooks
Expand Down
2 changes: 1 addition & 1 deletion docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ The authoritative session definitions live in the repository root `noxfile.py`.

### Linting and Type Checks

- `uv run nox -s precommit`: runs all prek/pre-commit hooks.
- `uv run nox -s precommit`: runs all prek/pre-commit hooks, except `no-commit-to-branch` (it exists to stop a direct commit to `main`, which isn't what this session is for). Run it explicitly with `uv run prek run no-commit-to-branch --all-files` if you need to check it.
- `uv run nox -s "pylint(package='coordinax')"`: run Pylint for the main package.
- `uv run nox -s "pylint(package='api')"`: run Pylint for `coordinaxs.api`.
- `uv run nox -s "pylint(package='astro')"`: run Pylint for `coordinaxs.astro`.
Expand Down
6 changes: 5 additions & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""Nox setup."""

import argparse
import os
import shutil
import tomllib
from enum import Enum
Expand Down Expand Up @@ -88,7 +89,10 @@ def lint(s: nox.Session, /) -> None:
@session(uv_groups=["lint"], uv_extras=["workspace"], reuse_venv=True)
def precommit(s: nox.Session, /) -> None:
"""Run the linter."""
s.run("prek", "run", "--all-files", *s.posargs)
# Not a real commit -- no-commit-to-branch would always fail here.
# Merge into any SKIP already set, rather than clobber it.
skip = ",".join(filter(None, [os.environ.get("SKIP"), "no-commit-to-branch"]))
s.run("prek", "run", "--all-files", *s.posargs, env={"SKIP": skip})


@session(uv_groups=["lint"], reuse_venv=True)
Expand Down
Loading