docs: Enable Ruff formatting of Python code blocks in Markdown - #982
Open
vdusek wants to merge 2 commits into
Open
docs: Enable Ruff formatting of Python code blocks in Markdown#982vdusek wants to merge 2 commits into
vdusek wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #982 +/- ##
=======================================
Coverage 94.62% 94.62%
=======================================
Files 58 58
Lines 5248 5248
=======================================
Hits 4966 4966
Misses 282 282
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What & why
Ruff 0.16 formats Python code blocks embedded in Markdown files, and does so by default. In this repo the feature was inert because
[tool.ruff] includewas an allowlist of*.pyglobs, so no Markdown file ever reached the formatter. Adding**/*.mdand**/*.mdxturns it on, which means docs snippets are now held to the same formatting standard as the rest of the codebase instead of drifting by hand.MDX needs the explicit
extension = { mdx = "markdown" }mapping - without it Ruff would try to parse.mdxas Python and fail. Most of the Python snippets indocs/live in.mdx, so the mapping is what makes this useful here.No changes to the
lint/formatPoe tasks are needed.lintalready runsruff format --checkandformatalready runsruff format, so both pick Markdown up automatically. Note thatruff check(lint rules) does not support Markdown yet, so only formatting is enforced there.Notes
docs/are formatted to 90 columns, not 120, because of the existingdocs/pyproject.tomloverride that keeps doc snippets free of a horizontal scrollbar. That is why one line in the upgrading guide got wrapped.includeallowlist to a single**/*.pyglob. This is a pure simplification: no tracked.pyfile lives outside the previously listed directories, and Ruff processes exactly the same 189 files before and after.✍️ Drafted by Claude Code