style: format Python code blocks in Markdown (ruff 0.16) - #233
Merged
Conversation
ruff 0.16 began formatting Python code blocks inside Markdown files. `ruff>=0.8` is unpinned, so CI picked the behaviour up and `make ci-python-lint` started failing on 74 documentation files the formatter had never touched before. Changes are confined to ```python fences: verified that zero prose lines changed across all 74 files (every added/removed non-blank line falls inside a python fence, using CommonMark fence rules). Also fixes 2 RUF036 errors (`None` not at the end of a type union) in modules/settings/settings/contracts/accessor.py, surfaced by the same ruff bump and independently failing the lint job. Annotation order only; runtime behaviour is unchanged and the settings suite (112 tests) passes. Claude-Session: https://claude.ai/code/session_01TtYUkaUAJmUcCwB5QGxPqN
Deploying simple-module-python with
|
| Latest commit: |
689fc76
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://eb15a5d7.simple-module-python.pages.dev |
| Branch Preview URL: | https://chore-ruff-format-markdown.simple-module-python.pages.dev |
#232 merged with the lint job overridden, bringing one new unformatted doc onto main. Formats it so `ruff format --check` is clean against the merged tree. Verified zero prose lines changed. Claude-Session: https://claude.ai/code/session_01TtYUkaUAJmUcCwB5QGxPqN
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.
Unblocks the
Python lint & formatCI job, which is currently red onmainand therefore on every open PR.Why
ruff>=0.8is unpinned. ruff 0.16 began formatting Python code blocks inside Markdown, a behaviour no one opted into — it arrived with a routine minor bump. CI installs ruff fresh each run, somake ci-python-lintstarted failing repo-wide:What changed
74 markdown files — reformatted by
ruff format.Changes are confined to
```pythonfences. I verified this mechanically rather than by eye: parsing both revisions with CommonMark fence rules (a closing fence is a bare backtick run ≥ the opening run, with no info string) and checking that every added/removed non-blank line falls inside a python fence.The formatter mostly normalises blank lines between defs, collapses aligned trailing-comment columns, and expands compact call sites. No prose, headings, or non-Python fences are touched.
1 Python file —
modules/settings/settings/contracts/accessor.py, 2 ×RUF036(Nonenot at the end of a type union), from the same ruff bump:These fail the same lint job independently, so the job stays red without them. Annotation order only — unions are order-independent, and the runtime
isinstance(user_id, _Unset)dispatch is unchanged.Verification
ruff format --check .ruff check .ty checkpytest modules/settingsNote on scope
Deliberately split out of #232 (perf) rather than folded in — that PR is a scoped performance change, and 74 files of formatter churn would have swamped its diff. Fixing it here on
mainalso clears it for every other open branch, not just that one.Considered and rejected: excluding
*.mdvia[tool.ruff.format] exclude, and pinningruff<0.16. The pin only defers the same 74 files to whoever lifts it.https://claude.ai/code/session_01TtYUkaUAJmUcCwB5QGxPqN