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 pyruff

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

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

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

# List rules
all_rules = pyruff.rules()
r = pyruff.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.11 — 3.14 support

Config Resolution

pyruff automatically discovers and applies your existing ruff configuration:

import pyruff

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

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

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

# Explicit params override config values
formatted = pyruff.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.11+ (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/emilt27/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.1rc5.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.1rc5-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.2 MB view details)

Uploaded PyPymanylinux: glibc 2.17+ x86-64

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

Uploaded PyPymanylinux: glibc 2.17+ ARM64

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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14macOS 11.0+ ARM64

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

Uploaded CPython 3.14macOS 10.12+ x86-64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.12macOS 10.12+ x86-64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

pyruff-0.15.1rc5-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.1rc5.tar.gz.

File metadata

  • Download URL: pyruff-0.15.1rc5.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.1rc5.tar.gz
Algorithm Hash digest
SHA256 7f61bd5afc6fbc82158ab8a076acaa3b835eea66a6fc8a73e272cb780e8a654e
MD5 65f11cd115f1da93f1ac0ccca0f1b5b8
BLAKE2b-256 4b0f6ceb1d094e4f2cdc2a835775fe7e4ba462487475e8412eafa68becf18696

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 702cc884a29f5d5dcb54e6711c7809bba938b8e25742c9a1a4ea13d4cafed883
MD5 d87ee6d47de80c5d7dd5f2c6fc1abdfb
BLAKE2b-256 0f638e1ec66fff4a296efa2735a67f3d11c28f3acad5a4a79d14fca18a3011a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7caac2f93d0ff8e6c8836b1a9168baceb47b0f40eac4f18c6dedf99082c791b3
MD5 ddb957fc0b3db57df2a0342c0e19668b
BLAKE2b-256 73f54fd0cd22a41e2827005fc1983e8030d5dbfc8074a12e10a515d280e642e4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp314-cp314t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f2901860fa3649e5959c5c9426225cc1966e0a96d695f59b6852df5ceccdca97
MD5 e99aa1d2aa8eac27cd173a31277b25d4
BLAKE2b-256 dba490ab06d0d54e28e2ac085752b43473f0210ed1313e55a002b65ed577bf1d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 3ab54ef02ef578a9ec2399d7d126ed04651e965c7d3dc90c7fb0ffee3a067475
MD5 223733df6a9f1fd54c26cb52fbfe23ea
BLAKE2b-256 9d8aa31b65bb89e978e8f36b9ba5d011dcba1e58517def655d099e36246d08ef

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4feb98d501bf495d7669b8675cb4231c7d543f44389c312fb0a43287aafe33cf
MD5 b6c95bb79e92ef40e92d30052c73a02a
BLAKE2b-256 6002e11bad52cd4c8198740bb448365a62a51a2c1421eb325aaee589eb51e962

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 69ce8e2209e36c2ed2e258dbd8e24d5e95195939215c6ffad1be8aded80d5c16
MD5 55a265fb780499f97be259ec42872e9d
BLAKE2b-256 370417b4d81b93040b7e8cf65af3287df1313cee5c35bba6e01ce931158ab431

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3020c9a8296879ce409985077b7cd74420689515c3669aa9de6be1ce3ef56606
MD5 e3d0614fac0023c8532226979e8b1e20
BLAKE2b-256 139ce64ccfa103ab5580f431216bacddf1cfcfe3178dd48d8472f5302fc09959

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp314-cp314-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d9abaa2e797c8b52ba2372cb690af0e0215f01572bc58f6ce9abb421c05986ad
MD5 fae7699d48c9be1b6957dd1e96a42468
BLAKE2b-256 a7b7ba8e7e5de4aacd691536f0ed53142310454b3dd5503bbc9a7ff8d9739fc8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ebf1146fe39f5e286177a4dae6b88db2c1cceb61d2b0ef0c7ed0e876316a1ec8
MD5 cfa3912b1c4c626e81fbf9eeccf609d9
BLAKE2b-256 964d201b00c26300692db39418cf2640618c762076e3ad3373386b818c1712a7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 89fdadabe129070e4ceded98842eea0e37508ef7593872b8d81e81fb3b465577
MD5 ef4c48b9bac96d6b38d6cc8cc72724cd
BLAKE2b-256 249c00d4a20f674f898d7ee5d0905f68dd6b4a36e24ed29e9b61dfb68f218b28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5046a9aae6765571fbbcc3551ceabd9be07bd0fb691a53be5f9ec7eda1c3c688
MD5 cd8b3d1b5a892e4777824890e341665f
BLAKE2b-256 4a2c68042377ce4fc926fe251e7e3fb73fdee42d50c46646f0e5763e4526b910

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 59d57311b9d06fb0abc92a42fcb66947711bc752d29883543e24e328e680462c
MD5 39bc0c6df02c6e726d0ceab83b21467e
BLAKE2b-256 b8fdc8c74f08821cacd3c853b56821f193590ac6d7c4afd75a22b400d12e8e9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a98dc54813389bcf79d6b10ce91727f2c9100d1f86ec54c0cefc7c3374589c3a
MD5 f84824c9ea08875acb1311b3571b3a53
BLAKE2b-256 475ca45d74775b2b106994965ca54fcb792f70b59c5ae500c5bf93bb3419e7ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3677bf7e0f5e1782d42352646abf346512fd51facc84287054271de4302517b9
MD5 9e93f80cb59e1de14b0c044c4440cde0
BLAKE2b-256 d8348a5e0ef74b30813b240458d7c83d1618cac29c694f2e5fce52b7f37468dc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 9c5025729cda2a5ea5674c0ebe52ab58e5514ef8224116e3c4fbdf613649d80c
MD5 94dd77b0ffe89edda5d59c30cda7ee68
BLAKE2b-256 b2ced6536c114d1d8eac994606598558c592d637b38584925c6946db84a9ae2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 61f313687b2b96483455346f1c3cce41eb9fa46e27bae629fc18c9e5f9c44129
MD5 47aeae0c8a217bc86d91e443dfb9594f
BLAKE2b-256 2fb9b7e37eb271212478ab0a24451e001fc9c0bffc15c6ab71d0f0c0bd480074

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e13f9234bb34a4041b0c6926669fe1c483c14a51583a78e9f0f02aeea8c0c08e
MD5 415171e80c8fc18f7eaf7c24e6a6ca32
BLAKE2b-256 b11f0eb5a93ace738fe692cc60681189bd8faea5d1e24ba36f48653638c85646

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c8b67ad95edf5101dfda4b3811393f6588d08a53578e4d24194481e298da539
MD5 05dd5423dbc5caa9e7d3d09633440d15
BLAKE2b-256 b83fe73c178b8209fd0a74417035a3f4658b73b5be2a76e41c661e22dd7fe8d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4a6a7e521b56962f534dff3259e13afb4fa4feb2993cdf0729987c35b0756adb
MD5 407c8f60add45d547a571c9d952c6028
BLAKE2b-256 644ed86ebb89478fb8c96e53c86cfb32914d31d0f50d9a560fc5bbf72c46f698

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ea9f9cbdcae2be20eaef9d944cb781dd5c79041e01a7aba63a41ec8c7f6444a4
MD5 b1beeee2318ca385c66fc122e7629ff8
BLAKE2b-256 73fbbd905fbf6f3345ca5382bc603bbec6df91f01e0575ecd3b8f36246bbb28a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 323609f12161ce8ef5c55df3d7efc414cd4ca58662d08313396d11ed6c97bdda
MD5 f23e9838da22319f3d3441f59190d3dc
BLAKE2b-256 9d1f45a0fc96db92d6a49c23ed10954e0ce39eceb4933275d7cddac80360f131

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5bae8edf01d158ba07e1339fa74ccd88e8b67c6e0d192d87b12a2f5722afcce5
MD5 0fc1288423df9067d817e865ea78aeac
BLAKE2b-256 a01abfa5b6cae7cc7518697730951f677f658e47f80eed75a4829c5e5161d4a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 18f18eb405b4ffa9340d3fbaddaee1070aceb8dd2428b451f7f37363f5bc2775
MD5 3d1dc8651c7536a91d5fdb3ab2551ef5
BLAKE2b-256 f30a4a9e44a2851a099ab48068ebaf305d9a0b2542862e98badfbd315a206358

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyruff-0.15.1rc5-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 710adb5167fceca19c730545900cb6ddc9fd5c23272de81425e74f4b3bef404a
MD5 fb82980ab0d518cd33dfbb61a6ade657
BLAKE2b-256 fc7a883fc86f8742b300170b8063d36e9c2b556c00c9a5f6ba7646dac6dcc566

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