Skip to main content

Native Python API for Ruff linter and formatter

Project description

pyruff

Native Python API for the Ruff linter and formatter.

pyruff compiles Ruff's Rust crates directly into a Python extension module via PyO3 and Maturin. No ruff CLI needed at runtime — everything runs natively in-process with zero overhead.

Installation

pip install pyruff

Quick Start

import ruff

# Format code
formatted = ruff.format_string("x=1\n")
# "x = 1\n"

# Lint code
diagnostics = ruff.check("import os\n")
for d in diagnostics:
    print(f"{d.code}: {d.message}")
# F401: `os` imported but unused

# Auto-fix violations
result = ruff.fix("import os\nimport sys\nprint(sys.path)\n")
print(result.output)
# import sys\nprint(sys.path)\n

# List rules
all_rules = ruff.rules()
r = ruff.rule("F401")
print(f"{r.code}: {r.name} ({r.linter})")

Features

  • Lintingcheck(), check_file(), check_paths() with full rule selection
  • Auto-fixfix() with safe/unsafe fix support
  • Formattingformat_string(), format_file() with all formatting options
  • Rulesrules(), rule(), linters() for rule metadata and introspection
  • Config resolution — Automatically discovers ruff.toml / pyproject.toml config, just like ruff CLI
  • Python 3.12 — 3.14 support

Config Resolution

pyruff automatically discovers and applies your existing ruff configuration:

# Auto-discovers ruff.toml / pyproject.toml from CWD
diagnostics = ruff.check("import os\n")

# Explicit config path
diagnostics = ruff.check("import os\n", config="path/to/ruff.toml")

# Ignore all config, use defaults
diagnostics = ruff.check("import os\n", isolated=True)

# Explicit params override config values
formatted = ruff.format_string(code, line_length=120)

Versioning

pyruff's version matches the ruff version it's built against. For example, pyruff==0.15.1 uses ruff 0.15.1 crates internally.

Documentation

Development

Prerequisites

  • Python 3.12+ (3.14 supported)
  • Rust 1.91+ (install via rustup)
  • Maturin (Python build tool for Rust extensions)

Setup

# Clone the repo
git clone https://github.com/your-org/pyruff.git
cd pyruff

# Create virtual environment
python -m venv .venv
source .venv/bin/activate  # or .venv\Scripts\activate on Windows

# Install dev dependencies
pip install maturin pytest ruff

Build

# Development build (debug, installed in .venv)
maturin develop

# Or use the helper script
bin/build

Run Tests

pytest tests/ -v

# Or use the helper script
bin/test

Linting & Formatting

# Rust
cargo fmt --check
cargo clippy -- -D warnings

# Python
ruff check python/ tests/
ruff format --check python/ tests/

# Or use the helper scripts
bin/lint
bin/fmt-check

Helper Scripts

The bin/ directory contains convenience scripts for common dev tasks:

Script Description
bin/build Build and install in dev mode
bin/test Run all tests
bin/lint Run all linters (Rust + Python)
bin/fmt Format all code (Rust + Python)
bin/fmt-check Check formatting without changes
bin/ci Run full CI pipeline locally

Release

Releases are automated via GitHub Actions. To release a new version:

  1. Update version in Cargo.toml and pyproject.toml
  2. Commit and push
  3. Create a git tag: git tag v0.15.1 && git push origin --tags
  4. CI builds wheels for Linux/macOS/Windows and publishes to PyPI

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyruff-0.15.1rc3.tar.gz (39.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyruff-0.15.1rc3-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.1 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ ARM64

pyruff-0.15.1rc3-cp314-cp314-win_amd64.whl (7.5 MB view details)

Uploaded CPython 3.14Windows x86-64

pyruff-0.15.1rc3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

pyruff-0.15.1rc3-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ ARM64

pyruff-0.15.1rc3-cp314-cp314-macosx_11_0_arm64.whl (7.5 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pyruff-0.15.1rc3-cp314-cp314-macosx_10_12_x86_64.whl (7.8 MB view details)

Uploaded CPython 3.14macOS 10.12+ x86-64

pyruff-0.15.1rc3-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.1 MB view details)

Uploaded CPython 3.13tmanylinux: glibc 2.17+ ARM64

pyruff-0.15.1rc3-cp313-cp313-win_amd64.whl (7.5 MB view details)

Uploaded CPython 3.13Windows x86-64

pyruff-0.15.1rc3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyruff-0.15.1rc3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64

pyruff-0.15.1rc3-cp313-cp313-macosx_11_0_arm64.whl (7.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyruff-0.15.1rc3-cp313-cp313-macosx_10_12_x86_64.whl (7.8 MB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

pyruff-0.15.1rc3-cp312-cp312-win_amd64.whl (7.5 MB view details)

Uploaded CPython 3.12Windows x86-64

pyruff-0.15.1rc3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

pyruff-0.15.1rc3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64

pyruff-0.15.1rc3-cp312-cp312-macosx_11_0_arm64.whl (7.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyruff-0.15.1rc3-cp312-cp312-macosx_10_12_x86_64.whl (7.8 MB view details)

Uploaded CPython 3.12macOS 10.12+ x86-64

File details

Details for the file pyruff-0.15.1rc3.tar.gz.

File metadata

  • Download URL: pyruff-0.15.1rc3.tar.gz
  • Upload date:
  • Size: 39.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.12.0

File hashes

Hashes for pyruff-0.15.1rc3.tar.gz
Algorithm Hash digest
SHA256 fb08ec82e4fff1b0a3a492af9603ba952476dbb87595648ebf8bfbd6ab5d169d
MD5 432f2986577ff330957f176cfaad4f6e
BLAKE2b-256 849f750b375563385a955372dc8c5a8a3dfd5034ca92cb708a58392db92b8b52

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cc7ea231304c30d4620d428c890e4d99027100da1426c1671bf86eb108bf071b
MD5 7870b3528855533eab1ae0ad885f0344
BLAKE2b-256 d117def609a05acd9e92e541fd5c4cdf1812efe6d1b91c0d539ba1d1997da425

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 23792cbc92a8a00d2542773ee17035fb0fdcf5e05985042b0fd234d9f2db1ad7
MD5 d4348997ce45a11bd43479829c42f696
BLAKE2b-256 eb55c0c1b24c8be27a7ec0723125bd4a3a7e419594887e851f8d9ccd4e9d5fe2

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b38c0a2c7362119c50bdd6cfefc3cb098bf404f0fbb9fc58fc286fbf9c932da3
MD5 f6634aa51a6f64bd442642ce37af847c
BLAKE2b-256 766b1796c3726232ea6222b2015461e1f9b2e336bdf3426a8e578e26001e93c3

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a90a349577ebb4e5fb9a908083937d40813a9f9b8c5b47cb16f7103c62eb168d
MD5 e7ebe8e94a56dd5f056ef627652de03d
BLAKE2b-256 78390a7a210ff6a63537cca38da99ed5856509a8a24be08ba4a6ad08a725a0e0

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6d9b1a255524fbd0c415bbce0d417e59e38d73a410e4c07944a9dd1ae234328
MD5 9b718097e6e51d1dd4ec09f92b3d39ff
BLAKE2b-256 019479071a94d096c29687e692bf1631fab52641b062bd61bc025ecf5a6dea10

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp314-cp314-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f84d25e9115d99a13e24ae2af1b4f0f265d27f62699bd4aa42b0060c266201a4
MD5 a12a782523ef7a92378f88c40fa3fc80
BLAKE2b-256 ecb550160ccbef10e32fb876361306a3e37e7be864daeea6a7e37aab687dd60c

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 683ae4062a1cb4c2863f0e9349839786fda4fd0764adf1ccbf0956a7168d83e6
MD5 525f2cf267f591fb07d7d12301e034e0
BLAKE2b-256 01a6771e6beb594778098bff2a01af11a3461642088531c082e46afd0474d8f6

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7f42f50692c998973334db11422ea897b85e5f009e3a4a77f503bd5d63526253
MD5 7f096666f4a9fd4711fcfddf6b3fb4a4
BLAKE2b-256 92767d7c47717163f174456cbf08d51b25f8d8ba93fa38ebe1a669000e888b30

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 52344397a125fdfcd88fa30fb872f005b61ec3032faf9eb3ec8b2bcec17f2dae
MD5 2eb9a0881213809bca87ad541179ad51
BLAKE2b-256 0879cd89961c212225159f4bb0fbc16576451eda5cea1058cb11e348e8262610

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e809e1eae1a6df4064f5d54d31f6c4b9b0318c71c0b37f089c30cdae9f557c17
MD5 ed42b84bc0ed57148ada2a2ec71d96cd
BLAKE2b-256 750a8de5c731ff9f0e92a78f18e9f3e0828f2bf7a68c5bb2cf451024da8ce567

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f731da2cc434c5beab6795ad26dbda89fbea420d3c1a291e46142c007daa36df
MD5 145deff3aaf970db18f60e1864ce0cdb
BLAKE2b-256 e485d8b87c634a2df5abd5c2894d927da00fe2eb9f50e338e40a79ec85a600f3

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 f1fbb151eccbc563cb870ea2b344f48270a819a45387a0a5a38831db71bc9d80
MD5 c0de6651711f65632cc2350031bd6a89
BLAKE2b-256 e80b7daf40824ecc3a9c00b92905fdc3ec7ede206ae4d39b12fc25220c1983d3

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5dcf3523b1155231d8ccf0b89027ea7185a8bbbbbb7e817792b3007a6d1228cb
MD5 4aa006714c2546ba0db261250ae81a6d
BLAKE2b-256 a92ec0ab50e5c31d398e51b35f658f3d09c523c5fe003f6619fa9570ce953b4d

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2f69ca0458ce2d5d66983a013d89793cdf9b0ee8578b683742ff913b37292bae
MD5 b6db20215da7bf604d1ba662323e28f9
BLAKE2b-256 6c7c7094fc8fb3a6009311403b1083336f365be48fad53c4a0c017eed06d1ea0

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5118e11dc5a4d4555159d65a607ba1e39cfc45732368a57399204b38a8a61342
MD5 4bd150443563ede4948bd98a0f510104
BLAKE2b-256 3c5b36335dda38f02f09988767e0bad0c31818b2bb386b93e925992e573d3623

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cd4d3a6074aba43da3c51d0cf9819cc154ada664baef764456f53e3c8f6dfcc1
MD5 daa21981206b8c275c8a2c91b0fb8ac8
BLAKE2b-256 ad53150381cfe0cacc51b01b3ef3c81c6f5613484b29809b3c617e9ef097b57c

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc3-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc3-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a9191cb5b1b25d03f072c5f9a1e8d8470cf3410f8de7443ffbe0a086b0d8c03f
MD5 7ce20a7dff144a41036f488666ab58cd
BLAKE2b-256 811f4ff5ab9a2eae369c2da2319441aabb8dc24b8af13d298a6faa884244f804

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page