docs: Enable Ruff formatting of Python code blocks in Markdown (#982)
### 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] include` was an allowlist of `*.py` globs, so no Markdown
file ever reached the formatter. Adding `**/*.md` and `**/*.mdx` turns
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 `.mdx` as Python and fail. Most of
the Python snippets in `docs/` live in `.mdx`, so the mapping is what
makes this useful here.
No changes to the `lint` / `format` Poe tasks are needed. `lint` already
runs `ruff format --check` and `format` already runs `ruff format`, so
both pick Markdown up automatically. Note that `ruff check` (lint rules)
does not support Markdown yet, so only formatting is enforced there.
### Notes
- Code blocks under `docs/` are formatted to 90 columns, not 120,
because of the existing `docs/pyproject.toml` override that keeps doc
snippets free of a horizontal scrollbar. That is why one line in the
upgrading guide got wrapped.
- The second commit collapses the `include` allowlist to a single
`**/*.py` glob. This is a pure simplification: no tracked `.py` file
lives outside the previously listed directories, and Ruff processes
exactly the same 189 files before and after.
*✍️ Drafted by Claude Code* V
Vlada Dusek committed
5a48589e9cfb98f5cd4e39911d1389cc92e85d5f
Parent: 784006e
Committed by GitHub <noreply@github.com>
on 7/29/2026, 5:05:23 PM