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.1rc4.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.1rc4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.3 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

pyruff-0.15.1rc4-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.1 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ ARM64

pyruff-0.15.1rc4-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.1rc4-cp314-cp314-win_amd64.whl (7.5 MB view details)

Uploaded CPython 3.14Windows x86-64

pyruff-0.15.1rc4-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.1rc4-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.1rc4-cp314-cp314-macosx_11_0_arm64.whl (7.5 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.12+ x86-64

pyruff-0.15.1rc4-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.1rc4-cp313-cp313-win_amd64.whl (7.5 MB view details)

Uploaded CPython 3.13Windows x86-64

pyruff-0.15.1rc4-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.1rc4-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.1rc4-cp313-cp313-macosx_11_0_arm64.whl (7.5 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

pyruff-0.15.1rc4-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.1rc4-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.1rc4-cp312-cp312-macosx_11_0_arm64.whl (7.5 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

pyruff-0.15.1rc4-cp311-cp311-win_amd64.whl (7.5 MB view details)

Uploaded CPython 3.11Windows x86-64

pyruff-0.15.1rc4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

pyruff-0.15.1rc4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (8.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64

pyruff-0.15.1rc4-cp311-cp311-macosx_11_0_arm64.whl (7.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyruff-0.15.1rc4-cp311-cp311-macosx_10_12_x86_64.whl (7.8 MB view details)

Uploaded CPython 3.11macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: pyruff-0.15.1rc4.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.1rc4.tar.gz
Algorithm Hash digest
SHA256 45ff4264272350e7927aa4cdff756a9f4c3ff9f7db5d197103c3a33821658958
MD5 7830166ff076f7c7b5ef4e6377e652f0
BLAKE2b-256 88f2c01bdba82bf123d348efeecabe82fc47842a9b9d51094de9760c45a8ea3f

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0dde070e04cb8e9d22c30656a02694ec178feb3286c68c805e0919bd1b980d46
MD5 f3c8c627139f42327aa2319c38628277
BLAKE2b-256 a627a7136c6e675b4b2c3a4be67ff9c409991f376702844d64c90d73ffb149b8

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc4-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b084ae85855767349e62f3042ef1b214ce222c422d37f7004972aebdffcb749c
MD5 0b23c71a82023aa6cfc8724f241a0627
BLAKE2b-256 abc06c32094eed22b30fec20d8025b40016316b9fe1408e0da2c6186db787b80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 059e233f5947713f541109d7d6df3a3e717dd9f03c294c9ee949fed06567ea19
MD5 51e693ee6befd3ced2794bfc17e8dea9
BLAKE2b-256 60360c81c436d5c51c322eb51cf74d85673502ce4baaf3e10d84e96f7c9337d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 173e9f68766792531b8abc9f41bb5899848def42ac039a46ad8a481026e1dec2
MD5 59daf16bbc5de3a1f0590e8f34dd73fe
BLAKE2b-256 083a15d7daacbcf362eaff86a111fd6055f5a49117e228be1370c0cc2172fce4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d4d62c1ece88e83e5a0a5bb656675dbff4aac06aca62c3289f615212a8a7902e
MD5 bec3cd2b401ff72372a20fc084899937
BLAKE2b-256 30c60e6825216903b2998429b27c587c9e9ad964e3c685118928845d3a5e9999

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9f1d1040ae28f441b8aef329c99803b30f7c03cc7c965f7f018e76c3813d04cf
MD5 d7fac9211755dddbfebcdbcd74e04478
BLAKE2b-256 4c42bafde3452ef376340ece3c7a8df21e1e8c3fcf3124512e3bf0ef6d373245

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 328ce2c86cb89c5008829e4687ff9fcdbe52507f6ab717e4cdd84e7eaba98d49
MD5 e6bce2b82fb04958ee5173b313b942ff
BLAKE2b-256 007fb2d6234dd97c60bc176ad2cbba190299e9b84f3c866a6973105e4abe2a24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4ee19234b8d7186f344df9f4fc97eb81754c54235688211126d2306c9da20355
MD5 c8814c9f1e0f72b29731777a0fc82417
BLAKE2b-256 56e978da495610039b6aa4efde73f1ae39fae7cc47a4583c5177328dc7e5b70a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 146cad427c3372336c95f1dca9d8cde63ff91b1daa654773f7525a420219a6f6
MD5 c83e9d9ff7e179b952ed4d6d609c474d
BLAKE2b-256 907207a307c02cc9683728bd9925975e2355a32527493da29c28b6c489793874

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 cc49837bc59ece8172dea7d3f402002144742895a405f67eb4b1cc10c2f6d9bf
MD5 23c32c861f6762b52eb4dd93927705d4
BLAKE2b-256 f45193faa084486683f23cb62d694af06884a5fb765e2d3b6f07e9da16fc6dea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3c472551679539ff2446fd77a988a9dc32668a8570c0d96e19403e0cfc3a9fb9
MD5 5c32f18922fff867a3590bd33514bbb1
BLAKE2b-256 55e92932080710c31d5d7fbbb98b60dfd7d253c1c80b471c17621f6bdc064560

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e476b23eb8374efa5579703e6eefd39d477da7fd6c21dc4387f71dc553ed6a39
MD5 b198d270e82dc61752c261ca50b62b49
BLAKE2b-256 911dfd3ab12bf196159f1309de161d1a31579209ee8c14fc3bc5dbf79ccbe04c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 89e5ed2a40d77250b7f0d16de5b45bf454a4a350af15d519b4d0eaada9c3987a
MD5 295dd39bafb50faf854f43ea9716d862
BLAKE2b-256 839206e88465768b741f9a7efc218dfcd052a5b31eae256ee561b28a703fab83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 87c84af422884a1bc3f695fc2875fe78b82b2b22bf53a264d22a1cc892455da0
MD5 ae0ddb23499f7cbb7e1a6a29eded6920
BLAKE2b-256 563c854b80cbe10bdd6060c7d317bc3a72b0e70f46fca7023b171a60e652a863

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 11e61745528ae941ba1ecf114fe071ad4c178f64e352dcc8a05aca355e9e9c28
MD5 843485f7cedabfd4a2c674a59783cc9c
BLAKE2b-256 f2a568afaba4a82934bf906e049a38631d248789d1038c4bf86bc8ffbe9372da

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3f6907d5bed6f9e73f53ccb65bb88278d80515577d9eaa990416533eefbdd889
MD5 06069f8f55379e4d045efc25f7c474cc
BLAKE2b-256 b1f49d5b9eb0f51fa5c903be418053668af0bfe92e72735976eb4fc50d252bfe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9732b2ea48c18d4bebbcd3ebca121b97630f5b11c33633375f04785c112c555c
MD5 8d04309bfd84f57c579e73053cad4962
BLAKE2b-256 9a36267fe8120d817ce800020b692ea54aa9e5a96125a0d85009f1ef93ba6816

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 271c327e45a3c5107986f50ace1888d8a2ea1d474ab3e46464255c56f36489ac
MD5 62891085bf4e4d096c46b4951c66069d
BLAKE2b-256 461671157938971003832e1a7386d1965c9313584da45a620b1a2e8ffcd2e58b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e92903c124e4752662923294244199378e1879fac713f52300503ba45d5bedbd
MD5 3eac832640bb869fb39cc6270fb9c3f8
BLAKE2b-256 9868c1a5539547a02447179fe1a5048bb7d18d9a6f49d864dfb23f285a5b970e

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 9ec1def0b165c20304297af44b81dc18c13e93e3c76b96dd86d032ecb1a75c55
MD5 cedeb6041f6ff984078828ce44037f0b
BLAKE2b-256 5d4bb3074da8bea6a1bc9a1c7df99d0fb534262690b517c7f3c6ffc19c69dc22

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a66c171ddfe08594f385783285c23fc7eb82a153af58a4dbb221dbb69488b177
MD5 fb45951baaeaeee75e28570dc5bcce41
BLAKE2b-256 1391060d343ba270f5514a5025b82578eba06bb0430bc8153dffada823e5082c

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 66c7c501c1699550a089374a5d0da8fca5c6dc598588f293debee70115b87082
MD5 b39bc09b515585ee4fe4bfe127dca6a0
BLAKE2b-256 d68ae153bf327d562f6770309bd11237c7a1cc7150ec53eea2959d7722999dd7

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eb4d80c85bd9dfa5efdbf924bce7005b1ea9b0e404343a1e10b49f8941d42fe3
MD5 a90c9c4e4ad20f4c35026a51541e0ce2
BLAKE2b-256 36397da84f2452bb3f2e6090c1a843608526a42551357bf2255958d4b5fda064

See more details on using hashes here.

File details

Details for the file pyruff-0.15.1rc4-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyruff-0.15.1rc4-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 823544af450520032e58e951d84749f74b2e4dcec93b5a021c1cae11027e4d5a
MD5 ca43c188e19a36cdce3cb20fc624dfb0
BLAKE2b-256 c34b46d19ced29ed366e2aa518518d7096e559606e70dcbde9f1354c17bab612

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