[GH-ISSUE #21641] feat: Add Ruff linter & formatter for Python code quality #58208

Closed
opened 2026-05-05 22:32:49 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @ashm-dev on GitHub (Feb 20, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/21641

Problem Description

The backend currently relies on black for formatting but has no linter configured. This means common code issues — unused imports, bare excepts, mutable default arguments, f-strings without placeholders, shadowed variables — go undetected and slip into the codebase silently.

Desired Solution

Add Ruff as both linter and formatter:

  • Add [tool.ruff] configuration to pyproject.toml with a practical rule set (E, F, W, I, UP, etc.)
  • Replace black with Ruff's built-in formatter (full black compatibility, 10-100x faster)
  • Apply autofixes across the backend

I already have a working local branch with these changes and I'm ready to fully take this on and submit a PR.

Alternatives Considered

  • Keep black + add flake8/pylint — works but means maintaining multiple tools with separate configs. Ruff covers both in a single, faster package.
  • Status quo — leaves easily preventable bugs and inconsistencies uncaught.

Additional Context

Ruff is already adopted by FastAPI, Pydantic, Hugging Face Transformers, and other major Python projects. It's a single Rust-based tool that replaces black, isort, flake8, pyupgrade, and dozens of other plugins with near-instant execution.

Originally created by @ashm-dev on GitHub (Feb 20, 2026). Original GitHub issue: https://github.com/open-webui/open-webui/issues/21641 ### Problem Description The backend currently relies on `black` for formatting but has no linter configured. This means common code issues — unused imports, bare excepts, mutable default arguments, f-strings without placeholders, shadowed variables — go undetected and slip into the codebase silently. ### Desired Solution Add [Ruff](https://docs.astral.sh/ruff/) as both linter and formatter: - Add `[tool.ruff]` configuration to `pyproject.toml` with a practical rule set (`E`, `F`, `W`, `I`, `UP`, etc.) - Replace `black` with Ruff's built-in formatter (full `black` compatibility, 10-100x faster) - Apply autofixes across the backend I already have a working local branch with these changes and I'm ready to fully take this on and submit a PR. ### Alternatives Considered - **Keep `black` + add `flake8`/`pylint`** — works but means maintaining multiple tools with separate configs. Ruff covers both in a single, faster package. - **Status quo** — leaves easily preventable bugs and inconsistencies uncaught. ### Additional Context Ruff is already adopted by FastAPI, Pydantic, Hugging Face Transformers, and other major Python projects. It's a single Rust-based tool that replaces `black`, `isort`, `flake8`, `pyupgrade`, and dozens of other plugins with near-instant execution.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#58208