{"id":9259,"library":"python-lsp-ruff","title":"Ruff linting plugin for pylsp","description":"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.","status":"active","version":"2.3.1","language":"en","source_language":"en","source_url":"https://github.com/python-lsp/python-lsp-ruff","tags":["LSP","linting","formatting","ruff","pylsp","IDE tools","code quality","developer tools"],"install":[{"cmd":"pip install python-lsp-server ruff python-lsp-ruff","lang":"bash","label":"Install in same virtual environment"}],"dependencies":[{"reason":"This library is a plugin for python-lsp-server, providing Ruff's functionality within the LSP framework.","package":"python-lsp-server"},{"reason":"python-lsp-ruff relies on the Ruff executable for all linting and formatting operations.","package":"ruff>=0.2.0"}],"imports":[{"note":"python-lsp-ruff is a plugin for python-lsp-server and is not imported or used directly in application code. Its functionality is exposed via the Language Server Protocol client (e.g., IDE/editor configuration).","symbol":"Not directly imported"}],"quickstart":{"code":"{  \n  \"python\": {  \n    \"linting\": {  \n      \"ruff\": {  \n        \"enabled\": true,  \n        \"config\": \"/path/to/pyproject.toml\"  \n      }  \n    },  \n    \"formatting\": {  \n      \"ruff\": {  \n        \"enabled\": true,  \n        \"format\": [\"I\"]  \n      }  \n    },  \n    \"plugins\": {  \n      \"pycodestyle\": {\"enabled\": false},  \n      \"pyflakes\": {\"enabled\": false}  \n    }  \n  }\n}","lang":"json","description":"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`."},"warnings":[{"fix":"To enable import sorting, add `format = ['I']` to your `ruff` configuration within your LSP client settings.","message":"Version 2.0.0 introduced breaking changes to code formatting. It now uses `ruff format` directly, and the default import sorting was removed.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure that your installed `ruff` version meets the minimum requirement specified by `python-lsp-ruff` (e.g., `ruff>=0.2.0` for `python-lsp-ruff>=2.1.0`). If using an older `ruff` (<0.1.0), you might need to pin `python-lsp-ruff==1.5.3`.","message":"Versions 2.1.0 and 1.6.0 introduced breaking compatibility requirements with `ruff`. Older `python-lsp-ruff` versions might not work with newer `ruff` versions, and vice-versa.","severity":"breaking","affected_versions":">=1.6.0, >=2.1.0"},{"fix":"Understand your LSP setup: if you use `python-lsp-server` for multiple language features, `python-lsp-ruff` is the correct choice to integrate Ruff. If you primarily want Ruff's features as a standalone LSP, consider `ruff-lsp` directly.","message":"Ruff itself ships with a built-in LSP server (`ruff-lsp` or `ruff server`) since `ruff>0.4.5`. This can be confused with `python-lsp-ruff`, which is a plugin for `python-lsp-server`. They serve different integration patterns.","severity":"gotcha","affected_versions":"All"},{"fix":"Prioritize configuring Ruff directly in your `pyproject.toml` or `ruff.toml` for project-specific settings to ensure consistent behavior across tools and contributors.","message":"When a `pyproject.toml` or `ruff.toml` file is present in your project, `python-lsp-ruff` will often defer to its configuration, ignoring some options passed via `pylsp` settings.","severity":"gotcha","affected_versions":"All"},{"fix":"If you need to use these other tools alongside Ruff, you must explicitly re-enable them in your LSP client's configuration, ensuring no rule conflicts exist.","message":"`python-lsp-ruff` disables other linters/formatters (e.g., `pycodestyle`, `pyflakes`, `mccabe`, `autopep8`, `yapf`, `flake8`, `pyls_isort`) by default to avoid duplicate diagnostics.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `ruff` is installed (`pip install ruff`) and accessible, and that both `python-lsp-server` and `python-lsp-ruff` are installed in the *same* virtual environment where your LSP client expects them. Reinstalling all three into a fresh virtual environment is a common fix.","cause":"The `ruff` executable is not found in the system's PATH, or `python-lsp-server` and `python-lsp-ruff` are not installed within the same Python virtual environment.","error":"Plugin 'ruff' did not respond in time / Ruff not running in editor"},{"fix":"Add `\"format\": [\"I\"]` to your `ruff` formatting configuration within your LSP client settings to re-enable import sorting.","cause":"Since `python-lsp-ruff` v2.0.0, the default import sorting functionality was removed when `ruff format` was integrated.","error":"Code formatting not working as expected / Imports are not sorted automatically"},{"fix":"Configure `ruff`'s rules (e.g., `select`, `ignore`, `line-length`) directly in your `pyproject.toml` (under `[tool.ruff.lint]`) or `ruff.toml` file to ensure they are respected by the LSP server.","cause":"A `pyproject.toml` or `ruff.toml` file in the project root overrides `ruff` configurations provided via the LSP client's settings.","error":"Custom linting rules or ignores in LSP client settings are being ignored"},{"fix":"Update both `python-lsp-ruff` and `ruff` to their latest versions. Ensure your LSP client and any `jupyter-lsp` integrations are also updated. Some specific editor configurations might be needed for full notebook support.","cause":"Older versions of `python-lsp-ruff` or `ruff` might struggle with `.ipynb` file extensions, preventing proper detection as Python code by the linter/formatter.","error":"Linter/formatter not working for Jupyter notebooks (.ipynb files)"}]}