Ruff linting plugin for pylsp

2.3.1 · active · verified Thu Apr 16

python-lsp-ruff is a plugin for python-lsp-server that integrates Ruff's linting, code actions, and formatting capabilities. It leverages Ruff, an extremely fast Python linter and formatter written in Rust, providing a fast and comprehensive code analysis experience. The library is actively maintained, with frequent updates (current version 2.3.1) for bug fixes and compatibility with newer Ruff versions.

Common errors

Warnings

Install

Imports

Quickstart

After installing `python-lsp-server`, `ruff`, and `python-lsp-ruff` in the same virtual environment, configure your LSP client (editor/IDE) to enable the Ruff plugin for `python-lsp-server`. This typically involves a JSON-like configuration for the language server. The example above shows how to enable Ruff for linting and formatting, explicitly re-enabling import sorting ('I') due to a breaking change in v2.0.0, and disabling other common Python linters to prevent conflicts. Remember to adjust paths and specific settings (e.g., `target-version`, `select`, `ignore`) according to your `ruff` configuration or `pyproject.toml`.

{  
  "python": {  
    "linting": {  
      "ruff": {  
        "enabled": true,  
        "config": "/path/to/pyproject.toml"  
      }  
    },  
    "formatting": {  
      "ruff": {  
        "enabled": true,  
        "format": ["I"]  
      }  
    },  
    "plugins": {  
      "pycodestyle": {"enabled": false},  
      "pyflakes": {"enabled": false}  
    }  
  }
}

view raw JSON →