Skip to content

style: format Python code blocks in Markdown (ruff 0.16) - #233

Merged
antosubash merged 3 commits into
mainfrom
chore/ruff-format-markdown
Aug 3, 2026
Merged

style: format Python code blocks in Markdown (ruff 0.16)#233
antosubash merged 3 commits into
mainfrom
chore/ruff-format-markdown

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Unblocks the Python lint & format CI job, which is currently red on main and therefore on every open PR.

Why

ruff>=0.8 is 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, so make ci-python-lint started failing repo-wide:

74 files would be reformatted, 538 files already formatted

What changed

74 markdown files — reformatted by ruff format.

Changes are confined to ```python fences. 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.

files checked       : 74
prose lines changed : 0

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 filemodules/settings/settings/contracts/accessor.py, 2 × RUF036 (None not at the end of a type union), from the same ruff bump:

-        user_id: str | None | _Unset = _UNSET,
-        tenant_id: str | None | _Unset = _UNSET,
+        user_id: str | _Unset | None = _UNSET,
+        tenant_id: str | _Unset | None = _UNSET,

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

Check Result
ruff format --check . 612 files already formatted
ruff check . All checks passed
ty check All checks passed
pytest modules/settings 112 passed

Note 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 main also clears it for every other open branch, not just that one.

Considered and rejected: excluding *.md via [tool.ruff.format] exclude, and pinning ruff<0.16. The pin only defers the same 74 files to whoever lifts it.

https://claude.ai/code/session_01TtYUkaUAJmUcCwB5QGxPqN

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
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 3, 2026

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

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

View logs

#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
@antosubash
antosubash merged commit 6f2adbf into main Aug 3, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant