Skip to main content

python-lsp-ruff

PyPi Anaconda Python

python-lsp-ruff is a plugin for python-lsp-server that adds linting, code actions and formatting capabilities that are provided by ruff, an extremely fast Python linter and formatter written in Rust.

Note that ruff>0.4.5 ships with a built-in LSP server (and ruff-lsp before that), which allows linting, formatting and code actions. In contrast, this implementation adds ruff as a plugin for pylsp in addition to pylsp's other functionalities (go-to support, ...).

Install

In the same virtualenv as python-lsp-server:

pip install python-lsp-ruff

There also exists an AUR package.

When using ruff before version 0.1.0

Ruff version 0.1.0 introduced API changes that are fixed in Python LSP Ruff v1.6.0. To continue with ruff<0.1.0 please use v1.5.3, e.g. using pip:

pip install "ruff<0.1.0" "python-lsp-ruff==1.5.3"

Usage

This plugin will disable pycodestyle, pyflakes, mccabe, autopep8, and yapf by default, unless they are explicitly enabled in the client configuration. When python-lsp-ruff is enabled, all linting diagnostics and formatting capabilities will be provided by ruff.

Any codes given in the format option will only be marked as fixable for ruff during the formatting operation, the user has to make sure that these codes are also in the list of codes that ruff checks!

Configuration

Configuration options can be passed to the python-language-server. If a pyproject.toml file is present in the project, python-lsp-ruff will ignore specific options (see below).

The plugin follows python-lsp-server's configuration. This example configuration using for neovim shows the possible options:

Lua
pylsp = {
  plugins = {
    ruff = {
      enabled = true,  -- Enable the plugin
      formatEnabled = true,  -- Enable formatting using ruffs formatter
      executable = "<path-to-ruff-bin>",  -- Custom path to ruff
      config = "<path_to_custom_ruff_toml>",  -- Custom config for ruff to use
      extendSelect = { "I" },  -- Rules that are additionally used by ruff
      extendIgnore = { "C90" },  -- Rules that are additionally ignored by ruff
      format = { "I" },  -- Rules that are marked as fixable by ruff that should be fixed when running textDocument/formatting
      severities = { ["D212"] = "I" },  -- Optional table of rules where a custom severity is desired
      unsafeFixes = false,  -- Whether or not to offer unsafe fixes as code actions. Ignored with the "Fix All" action
      unfixable = { "F401" }, -- Rules that are excluded when checking the code actions (including the "Fix All" action)

      -- Rules that are ignored when a pyproject.toml or ruff.toml is present:
      lineLength = 88,  -- Line length to pass to ruff checking and formatting
      exclude = { "__about__.py" },  -- Files to be excluded by ruff checking
      select = { "F" },  -- Rules to be enabled by ruff
      ignore = { "D210" },  -- Rules to be ignored by ruff
      perFileIgnores = { ["__init__.py"] = "CPY001" },  -- Rules that should be ignored for specific files
      preview = false,  -- Whether to enable the preview style linting and formatting.
      targetVersion = "py310",  -- The minimum python version to target (applies for both linting and formatting).
    },
  }
}
JSON
{
  "pylsp": {
    "plugins": {
      "ruff": {
        "enabled": true,
        "formatEnabled": true,
        "executable": "<path-to-ruff-bin>",
        "config": "<path_to_custom_ruff_toml>",
        "extendSelect": [ "I" ],
        "extendIgnore": [ "C90"],
        "format": [ "I" ],
        "severities": {
          "D212": "I"
        },
        "unsafeFixes": false,
        "unfixable": [ "F401" ],
        "lineLength": 88,
        "exclude": ["__about__.py"],
        "select": ["F"],
        "ignore": ["D210"],
        "perFileIgnores": {
          "__init__.py": "CPY001"
        },
        "preview": false,
        "targetVersion": "py310"
      }
    }
  }
}

For more information on the configuration visit Ruff's homepage.

Custom severities

By default, all diagnostics are marked as warning, except for "E999" and all error codes starting with "F", which are displayed as errors. This default can be changed through the pylsp.plugins.ruff.severities option, which takes the error code as a key and any of "E", "W", "I" and "H" to be displayed as errors, warnings, information and hints, respectively. For more information on the diagnostic severities please refer to the official LSP reference.

With v2.0.0 it is also possible to use patterns to match codes. Rules match if the error code starts with the given pattern. If multiple patterns match the error code, python-lsp-ruff chooses the one with the most amount of matching characters.

Code formatting

With python-lsp-ruff>1.6.0 formatting is done using ruffs own formatter by default. Formatting using ruff can be explicitly disabled by setting formatEnabled = false in the LSP settings. Additional rules that should be fixed during the textDocument/formatting request can be added with the format option.

Coming from previous versions the only change is that isort rules are not applied by default. To enable sorting of imports using ruff's isort functionality, add "I" to the list of format rules.

Code actions

python-lsp-ruff supports code actions as given by possible fixes by ruff. python-lsp-ruff also supports unsafe fixes. Fixes considered unsafe by ruff are marked (unsafe) in the code action. The Fix all code action only consideres safe fixes.

Debugging

The log level can be set via the cmd option of pylsp:

vim.lsp.config("pylsp",  {
  cmd = {"pylsp", "-vvv", "--log-file", "/tmp/lsp.log"},
  settings = {
    pylsp = {
      plugins = {
        ruff = {
          enabled = true,
        },
      }
    }
  }
})

Release files for python-lsp-ruff 2.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-lsp-ruff 2.3.3
File Size Uploaded
python_lsp_ruff-2.3.3.tar.gz 17.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for python-lsp-ruff 2.3.3
File Interpreter ABI Platform
python_lsp_ruff-2.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 29.4 kB

Release files / python_lsp_ruff-2.3.3.tar.gz

Download URL python_lsp_ruff-2.3.3.tar.gz
Size 17.4 kB
Tags Source
SHA-256 checksum
How to use checksums
156bfbbe2b6ef5d1a2d69500e0804677b64469fb59e41c4e77774fd3440a7f32
BLAKE2b-256 checksum
How to use checksums
6c840cfc69ab2cc8f553530e1bc595c76e9a2b786ace6b8e070c3d5b813ce6e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 17, 2026.

Transparency log

Release files / python_lsp_ruff-2.3.3-py3-none-any.whl

Download URL python_lsp_ruff-2.3.3-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e9f700233d0157a74cc7f739ec151c75a95aa53962bce0b959b6957761acc0a
BLAKE2b-256 checksum
How to use checksums
e7b4827f3205b70d77cc5ead2526afad77906cf8d53894012b155799113b0e40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 17, 2026.

Transparency log

Release history Release notifications | RSS feed

2.3.4

2 release files

This release

2.3.3 This release

2 release files

2.3.2

3 release files

2.3.1

2 release files

2.3.0

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.6.0

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page