--- id: ruff-format version: "0.5.4" license: MIT license_treatment: permissive maintenance: active --- # ruff-format — Python bindings for the Ruff code formatter, built with Rust and PyO3. License: permissive · Maintenance: active · Downloads: 97.9K/mo ## What it is and what it does ruff-format is a Python package that wraps Ruff's formatting engine, written in Rust and exposed via PyO3 bindings. It lets you format Python code from within your own Python programs rather than only via the command line. The package provides three main functions: is_valid_syntax to check syntax, parse_code to parse without formatting, and format_string to reformat code with a configurable line width (default 80). The package has no runtime dependencies and is distributed as prebuilt wheels for most platforms, though it does require Rust to build from source. It supports Python 3.8 through 3.14 and is actively maintained, with recent releases available. Use it for: - Programmatically format code snippets or user-submitted Python in a web application or IDE - Integrate code formatting into a custom linting or code review pipeline - Format Python code with a specific line width in a build or CI/CD workflow - Validate Python syntax before attempting to format or execute it ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides Python bindings to Ruff's code formatter, allowing you to format Python code programmatically with configurable line width. Yes, if you need to format Python code programmatically in your application. The package is actively maintained, has no runtime dependencies, and is backed by Ruff's well-regarded formatter. The medium install friction (compiled bindings) is offset by prebuilt wheels for most platforms. No known security issues. ## Install pip install ruff-format uv add ruff-format poetry add ruff-format ## Installing ruff-format Before you install: Medium install friction due to compiled Rust bindings, but prebuilt wheels are available for most platforms. Actively maintained with recent releases. License in practice: MIT license permits unrestricted use, modification, and distribution with minimal restrictions. Quickstart: from ruff_format import format_string code = "def hello( x,y, z ):\n print( x+y+z )" formatted = format_string(code) print(formatted) Requires Python 3.8 or later; prebuilt wheels available for most platforms, but source builds require Rust and maturin. Verify before relying: - Whether format_string handles all Python syntax edge cases or has known limitations - Performance comparison with other formatters on large codebases - Whether custom formatting rules beyond line_width are supported ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: medium - Maintenance: active - Downloads: 97.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags python code formatter, ruff formatter bindings, format python code programmatically, code formatting library, rust-powered formatter, format_string python, code-formatting, rust-bindings [View on SkillFed](https://skillfed.io/packages/ruff-format) · [View on PyPI](https://pypi.org/project/ruff-format/)