Use ruff format for Markdown when format_tool=ruff#42
Merged
Conversation
When the ruff formatter is selected, drop blacken-docs entirely and let ruff format handle Python code blocks in Markdown files (preview feature added in ruff 0.15.0). The black variant keeps using blacken-docs. - pyproject.toml: enable [tool.ruff.format].preview and extend-include for *.md so ruff format discovers Markdown files - pre-commit: drop blacken-docs and black-pre-commit-mirror hooks; add types_or with markdown to ruff-format - justfile: drop blacken-docs steps from format and deps-update - ctt: ignore PC111 (repo-review requirement to use blacken-docs) - drop black from dev deps when not using black
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.
Summary
ruff format(preview) to format Python code blocks inside Markdown files. Feature added in ruff 0.15.0.Changes
project_name/pyproject.toml.jinja: enable[tool.ruff.format].preview = trueand[tool.ruff].extend-include = ["*.md"]soruff formatdiscovers and formats Markdown files; dropblackfromdevdeps when not using Black.project_name/.pre-commit-config.yaml.jinja: drop theblacken-docsandblack-pre-commit-mirrorhooks for the ruff variant; addtypes_or: [python, pyi, jupyter, markdown]toruff-format.project_name/justfile.jinja: drop blacken-docs from theformatrecipe and_sync-blacken-docsfromdeps-updatefor the ruff variant; gate the_sync-blacken-docsrecipe behindformat_tool == "black".ctt.toml: ignorePC111(sp-repo-review requirement to use blacken-docs) since ruff format replaces it for the ruff variant.README.md,CONTRIBUTING.md.jinja: document the new behavior.Test plan
cttruff formatreformats Python code blocks inside*.mdfiles in the ruff variantruff checkskips*.mdfiles (lint not affected)blacken-docsstill present and runs for the Black variant