6.1 pre-commit, in the group lint

Read the tutorial. Build it yourself is the other way to read this part.

This walk goes through rahuldave/cheesecracker on GitHub. This part starts from the code at step-05. The code before this part

To look at this code on your machine, run these commands. The first one makes a clone, if this folder has none:

[ -d cheesecracker ] || git clone https://github.com/rahuldave/cheesecracker
cd cheesecracker
git fetch --quiet --tags --force origin
git switch --detach step-05
just setup

The whole tutorial then sets up ruff, and fixes the code with it. pre-commit runs the checks before every commit, so it joins ruff in the group lint.

6.1 pre-commit, in the group lint

pre-commit runs checks on the files of a commit, before git makes it. pre-commit calls each check a hook. git has hooks of its own, scripts that it runs before a commit, and a later move installs one of them to start pre-commit.

.pre-commit-config.yaml names the repository that each hook comes from, and the exact version to use. The first time pre-commit runs, it downloads each hook and installs it in a folder of its own. A failed check stops the commit. If a hook fixes a file, the commit stops too, and the fixed file waits for git add before the next try.

pre-commit checks the code, and the server does not need it to run. So it goes into the group lint, with ruff.

This change came from running uv add --group lint pre-commit.

uv run pre-commit --version

uv prints the version of pre-commit.

What changed

  • pyproject.toml: pre-commit, in the group lint. 1 line added. It comes from uv add --group lint pre-commit. The file
    • look at "pre-commit>=4.7.0",
  • uv.lock: the exact versions of pre-commit, and of the packages that it needs. 149 lines added, 1 removed. It comes from uv add --group lint pre-commit. The file

The diff of pyproject.toml
@@ -17,6 +17,7 @@ default-groups = "all"
 
 [dependency-groups]
 lint = [
+    "pre-commit>=4.7.0",
     "ruff>=0.17.1",
 ]
 test = [

This change on GitHub

This part ends at the code at f3ad230bf911, partway through step-06. The code after this part