Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ uv run stack
uv run flake8 --config tox.ini
```

Formatting uses `black` (available via `uv run black`). Linting config is in `tox.ini`.
Linting config is in `tox.ini`; `./scripts/lint.sh` runs what CI runs.

There is no autoformatter, deliberately. `max-line-length` is a ceiling, not a target: code
wrapped shorter than it is wrapped that way on purpose, and a formatter that joins those
lines back up to the limit is not wanted here. Match the wrapping of the surrounding code
by hand.

## Testing

Expand Down
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ requires-python = ">=3.10"
stack = "stack:main.cli"

[dependency-groups]
dev = ["flake8", "black", "pytest"]

[tool.black]
# Matches flake8's max-line-length in tox.ini. Without this black defaults to 88
# and reformats the whole file it is pointed at, so keep the two in step.
line-length = 132
dev = ["flake8", "pytest"]

[tool.pytest.ini_options]
testpaths = ["tests/unit"]
Expand Down
14 changes: 9 additions & 5 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/bin/bash

if [[ "$1" == "--fix" ]]; then
LINE_LENGTH=$(cat tox.ini | grep 'max-line-length' | cut -d'=' -f2 | awk '{ print $1 }')
uv run black -l ${LINE_LENGTH:-132} src/stack/
fi
#
# Lints the source. This is what CI runs, so it is the check to satisfy before
# pushing.
#
# There is deliberately no --fix: the formatter that used to live here (black
# -l 132) treats the line length as a target rather than a ceiling, so it joins
# hand-wrapped code into single long lines. Nothing in the source needs
# reformatting -- max-line-length in tox.ini is a limit, and wrapping shorter
# than it is a choice made for readability, not a defect to be corrected.

uv run flake8 --config tox.ini
Loading
Loading