Skip to main content

pytest-ruff-markdown

CI PyPI License: MIT

A pytest plugin that lints python / py fenced code blocks in Markdown files with ruff. Each fenced block in a collected .md file becomes its own pytest item.

Installation

Add it as a dev dependency in your project:

uv add --dev pytest-ruff-markdown

No further configuration is needed: once installed, pytest automatically collects every ```python/```py fenced block in any .md file it picks up (other fence languages, e.g. ```bash, are left alone) and lints it as its own test item. A violation is reported against the block's real line number in the Markdown file, not the block's own internal line numbers, so failures jump you straight to the offending line in your docs.

Usage notes

Each fenced block is linted as its own isolated file — it has no visibility into any other block in the same document, or into surrounding prose. That means F821/F401 can fire on names or imports that are actually defined in a different block (for example, a class split across two fences). This is intentional: isolated linting is what gives each block its own pass/fail and its own line number, and it's the plugin's main value. A block can opt out of linting entirely with a skip marker, or opt into sharing a preceding block's source as context with a continues marker:

<!-- pytest-ruff-markdown: skip -->
<!-- pytest-ruff-markdown: continues -->

Formatting (ruff format) is a mutation, not a check, so it runs via a separate console script instead of as a pytest item:

uv run pytest-ruff-markdown-format docs/tutorial.md

Each block is piped into ruff under a synthetic filename of the form {markdown-stem}__blockN.py, resolved next to the source Markdown file (e.g. docs/tutorial.md's second block becomes docs/tutorial__block2.py). This is a stable contract you can target with your own ruff per-file-ignores config to scope rules for embedded code specifically, without any plugin-specific configuration.

See the reference docs for full details on the markers, the synthetic filename contract for scoping your own ruff config, the D100 suppression, and the pytest-ruff-markdown-format CLI flags.

Metadata

Release files for pytest-ruff-markdown 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-ruff-markdown 0.2.0
File Size Uploaded Provenance Actions
pytest_ruff_markdown-0.2.0.tar.gz 10.2 kB Without provenance Details for pytest_ruff_markdown-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pytest-ruff-markdown 0.2.0
File Interpreter ABI Platform Actions
pytest_ruff_markdown-0.2.0-py3-none-any.whl Python 3 none any Details for pytest_ruff_markdown-0.2.0-py3-none-any.whl

Total release size: 23.7 kB

Release files / pytest_ruff_markdown-0.2.0.tar.gz

Download URL pytest_ruff_markdown-0.2.0.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
6601a47725395f89958b1ffc7d25d3440b9930fe1e61a6e7e848cc43392ac8c2
BLAKE2b-256 checksum
How to use checksums
93871115eb7981f254fe628bc043047ae9a9ca9dc01367924da55e9ef15372af
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / pytest_ruff_markdown-0.2.0-py3-none-any.whl

Download URL pytest_ruff_markdown-0.2.0-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e1e19b3c683848cbbda02df3b87d55168925db864bf500dd53111c266dcd4796
BLAKE2b-256 checksum
How to use checksums
5ad3ce75107b5f2c81717f83014f773a3710dac89c2a5f7b669281f45cbe1ae8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for pytest-ruff-markdown 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page