Ruff - Python Linter Written in Rust

Ruff - Python Linter Written in Rust



Ruff is an extremely fast Python linter written in Rust, 10-100x faster than existing tools.

GitHub


https://github.com/astral-sh/ruff

Key Benefits



1. Extreme Speed

  • 10-100x faster than Flake8
  • 20-50x faster than isort
  • 30-60x faster than Black


  • 2. All-in-One Tool


    Replaces multiple tools:
  • Flake8 (linting)
  • isort (import sorting)
  • pydocstyle (docstring checking)
  • pyupgrade (modernize Python code)
  • And more


  • 3. Compatibility

  • Full PEP 8 compliance
  • 600+ rules supported
  • Configurable ruleset


  • Installation



    ash
    pip install ruff

    or with uv


    uv pip install ruff


    Usage



    ash

    Check files


    ruff check file.py

    Check entire project


    ruff check .

    Auto-fix


    ruff check --fix .

    Format code


    ruff format file.py


    Configuration



    Create pyproject.toml:

    oml
    [tool.ruff]
    line-length = 88
    target-version = "py38"

    [tool.ruff.lint]
    select = ["E", "F", "I"]
    ignore = ["E501"]


    Performance



    | Tool | Django codebase check time |
    |------|--------------------------|
    | Flake8 | 40 seconds |
    | Ruff | 0.5 seconds |
    | Speedup | 80x |

    Why Ruff?

  • Save significant time
  • Unified toolchain
  • Active development (Astral team)
  • Continuous updates


  • Summary



    Ruff is essential for Python development. If you're using Flake8, migrate to Ruff today!




    Rating: 猸愨瓙猸愨瓙猸?
    Best for: Python projects
    Learning curve: 猸愨瓙猸?
    标签:

    💬 评论区 (0)

    暂无评论,快来抢沙发吧!