5.4 just fmt and just lint
Build it yourself. Read the tutorial is the other way to read this part.
This walk goes through rahuldave/cheesecracker on GitHub. This part starts from the code at 7c1670fd52a0, partway through step-05. The code before this part
This part does not start where the part before it ends, because the walk skips some changes. This command puts the files that this part starts from in place of yours. Run it, and then go on:
git fetch --quiet --tags --force origin; git restore --source step-04 --staged -- :/ && git restore --source 7c1670fd52a0 --staged --worktree -- :/If you start at this part, make your clone as Get the project says, and then run this command. It puts in your clone the files that this part starts from. A file that the project deleted before this part stays, so delete it if git check lists it:
git rm -rq --cached --ignore-unmatch -- :/ && git restore --source 7c1670fd52a0 --staged --worktree -- :/just setupThe whole tutorial then makes a change in a hurry. It adds ruff, one tool that does two jobs. As a formatter, it lays out the code in one fixed way. As a linter, it checks the code against rules. The tutorial gives ruff the rules of flake8, an older linter. The formatter and the linter get a recipe each.
5.4 just fmt and just lint run ruff
Two recipes give the formatter and the linter short names. Each passes on to ruff any words that you type after it.
Apply the patch to justfile, from the top of the project:
curl -fsSL https://github.com/rahuldave/cheesecracker/commit/b947593e84b71486902b3ff1c7f9e1458b70e3f7.diff | git apply --include=justfileRead the recipes fmt and lint at the end of the justfile.
just fmt --checkThe recipe fails as ruff format --check did, with 2 files would be reformatted.
Check your files against this move. The command prints nothing when they match, and otherwise shows what differs:
git check b947593e84b7If you are stuck, this command puts the files of this move in place of yours. A file that you made yourself stays:
git restore --source 7c1670fd52a0 --staged -- :/ && git restore --source b947593e84b7 --staged --worktree -- :/What changed
justfile: the recipesfmtandlint. 8 lines added. The file- look at
uv run ruff check "$@"
- look at
The patch to justfile
@@ -44,3 +44,11 @@ stop:
# Run the tests, and show which lines of the package api they ran. Extra arguments go to pytest: just cov tests/unit
cov *args:
uv run pytest --cov=api --cov-report=term-missing "$@"
+
+# Format the code, one way. Extra arguments go to ruff: just fmt --check, just fmt --diff
+fmt *args:
+ uv run ruff format "$@"
+
+# Check the code against the rules in pyproject.toml. Extra arguments go to ruff: just lint --fix
+lint *args:
+ uv run ruff check "$@"This part ends at the code at b947593e84b7, partway through step-05. The code after this part