Skip to content
This repository was archived by the owner on Aug 3, 2026. It is now read-only.

Commit cdf436b

Browse files
authored
docs: Enable Ruff formatting of Python code blocks in Markdown (#78)
### 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 twice over: the Ruff pin was `~=0.14.0`, which has no Markdown support at all, and `[tool.ruff] include` was an allowlist of `*.py` globs, so no Markdown file would have reached the formatter anyway. This bumps Ruff to `~=0.16.0` and adds `**/*.md` and `**/*.mdx` to `include`, together with the `extension = { mdx = "markdown" }` mapping that MDX needs (without it Ruff would try to parse `.mdx` as Python and fail). There is no Markdown in this repo containing Python code blocks today, so no file content changes - this is here to keep the four Apify Python repos configured identically. Ruff 0.16 flags `CPY001` (missing copyright notice) under `select = ["ALL"]`, so it is added to the ignore list, matching apify-sdk-python, apify-client-python and crawlee-python. 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 - The second commit collapses the `include` allowlist to a single `**/*.py` glob. This is a pure simplification: no tracked `.py` file lives outside `src/` and `tests/`, and Ruff processes exactly the same 8 files before and after. *✍️ Drafted by Claude Code*
1 parent 831e7a3 commit cdf436b

2 files changed

Lines changed: 30 additions & 23 deletions

File tree

pyproject.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ dev = [
5050
"pytest-timeout<3.0.0",
5151
"pytest-xdist<4.0.0",
5252
"pytest<10.0.0",
53-
"ruff~=0.14.0",
53+
"ruff~=0.16.0",
5454
"setuptools", # setuptools are used by pytest, but not explicitly required
5555
"ty~=0.0.0",
5656
]
@@ -61,12 +61,20 @@ source-include = ["CHANGELOG.md", "CONTRIBUTING.md"]
6161

6262
[tool.ruff]
6363
line-length = 120
64-
include = ["src/**/*.py", "tests/**/*.py"]
64+
include = [
65+
"**/*.py",
66+
# Ruff formats Python code blocks embedded in Markdown files.
67+
"**/*.md",
68+
"**/*.mdx",
69+
]
70+
# MDX is Markdown; without this mapping Ruff would try to parse `.mdx` files as Python.
71+
extension = { mdx = "markdown" }
6572

6673
[tool.ruff.lint]
6774
select = ["ALL"]
6875
ignore = [
6976
"COM812", # This rule may cause conflicts when used with the formatter
77+
"CPY001", # Missing copyright notice at top of file
7078
"D100", # Missing docstring in public module
7179
"D104", # Missing docstring in public package
7280
"D107", # Missing docstring in `__init__`

uv.lock

Lines changed: 20 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)