feat: use ruff to format docs code instead of blacken-docs - #833
Merged
Conversation
henryiii
force-pushed
the
ruff-016-markdown-docs
branch
from
July 24, 2026 05:12
cc2937c to
ebe1a42
Compare
Ruff 0.16 formats Python code blocks in Markdown, so a single tool covers both code and docs. Drop the blacken-docs hook, bump ruff-pre-commit to v0.16.0, and add markdown to the ruff-format hook's types_or. PC111 now passes with either blacken-docs or a ruff-format hook that lists markdown in types_or. Assisted-by: ClaudeCode:claude-opus-4.8
Assisted-by: ClaudeCode:claude-opus-4.8
henryiii
force-pushed
the
ruff-016-markdown-docs
branch
from
July 24, 2026 05:18
ebe1a42 to
99b32d8
Compare
Ruff's pre-commit hook will format Markdown by default at some point. Pass PC111 unless the ruff-format hook filters Markdown out, instead of requiring a literal `markdown` entry. Assisted-by: ClaudeCode:claude-opus-5
Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
Alexboiboi
added a commit
to magpylib/magpylib
that referenced
this pull request
Aug 26, 2026
* Update from scientific-python/cookie template `2026.08.14` Ran `copier update` from `2026.04.04`. Notable upstream changes: - blacken-docs is gone; ruff-format now handles markdown, jupyter and pyproject code blocks instead (scientific-python/cookie#833). - The ruff `extend-select` list drops BLE, DTZ, FA, FLY, I, PIE and YTT, which Ruff 0.16 selects by default (scientific-python/cookie#843). - zizmor joins pre-commit, with `.github/zizmor.yml` allowing ref pins. - Workflows gain a top level `permissions: {}` with per-job grants, and `persist-credentials: false` on checkout. - `actions/attest-build-provenance` -> `actions/attest`, which generates SLSA build provenance when handed no predicate inputs. - Dependabot gets a seven day cooldown. Conflicts were resolved in favour of ours wherever the project has deliberately diverged: the Read the Docs `commands:` block stays (it needs libgl1-mesa-dev and sphinx-apidoc, so only the interpreter bump to 3.14 was taken), as do the disabled mypy hook (rev synced to v2.3.0 for whenever it is enabled), the pyvista headless display and pypy OpenBLAS steps, the note explaining the hynek pin, and our test matrix. The checks job also sheds a duplicate `astral-sh/setup-uv` invocation and an `allow-prereleases` input that was being handed to setup-uv, which has no such input. Both arrived in #954. Python now comes from setup-python again, as the template intends. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * Reformat docs code blocks with ruff-format Falls out of swapping blacken-docs for ruff-format in the template update: an implicit f-string concatenation collapses onto one line, `{i+1}` gains spaces around the operator, and two blank lines after a `for` go away. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> * Pin the CI matrix interpreter for uv Now that setup-python provides the interpreter rather than setup-uv, `uv sync` is no longer handed one explicitly and discovers it off PATH. Setting UV_PYTHON keeps the matrix honest: a discovery mismatch would fail open and test the same version twice under two different job names. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I think "markdown" will be added to the hook, in which case this simplifies. See astral-sh/ruff-pre-commit#159.
Close #343.
🤖 AI text below 🤖
Ruff 0.16 can format Python code blocks in Markdown, a stable
blacken-docsreplacement, so one tool now covers both code and docs.blacken-docshook, bumpruff-pre-committov0.16.0, and addmarkdownto theruff-formathook'stypes_or(the hook filters files, so Markdown must be listed).PC111retitled to "Formats code in docs"; it now passes with eitherblacken-docsor aruff-formathook that hasmarkdownintypes_or. Still flags the oldasottile/blacken-docsURL.blacken-docsfor Black users or reStructuredText (which ruff doesn't format); bumped ruff revs tov0.16.0.docs/principles/design.md(a trailing comma).Ruff 0.16 also expands the default rule set, but the guide already recommends an explicit
select, so that change doesn't affect projects following it.📚 Documentation preview 📚: https://scientific-python-cookie--833.org.readthedocs.build/