Skip to content

reflex-dev/ruff-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ruff-format

A fast Python code formatter powered by Ruff's formatting engine.

Overview

ruff-format is a Python package that provides Python bindings to Ruff's Python formatter.

Installation

pip install ruff-format

Usage

from ruff_format import format_string, is_valid_syntax, parse_code

code = """
def hello(  x,y,   z  ):
    print( x+y+z )
"""

# Check if code has valid syntax
assert is_valid_syntax(code)

# Parse code (raises RuntimeError on syntax errors)
parse_code(code)

# Format code (default line width: 80)
formatted = format_string(code)
print(formatted)

# Format with a custom line width
formatted = format_string(code, line_width=120)
print(formatted)

Development

Prerequisites

  • Rust (latest stable)
  • Python 3.8+
  • maturin

Building from source

# Install maturin
pip install maturin

# Build the package
maturin develop

# Or build a release version
maturin build --release

License

MIT

Links

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors