Ruff v0.4.5 is available now! Install it from PyPI, or your package manager of choice:
pip install --upgrade ruff
Ruff is an extremely fast Python linter and formatter, written in Rust. Ruff can be used to replace Black, Flake8 (plus dozens of plugins), isort, pydocstyle, pyupgrade, and more, all while executing tens or hundreds of times faster than any individual tool.
This release marks the Beta release of our integrated, Rust-based language server, which powers the diagnostic and formatting capabilities of Ruff’s VS Code extension and other editor integrations.
Last month, we released the Alpha version as part of Ruff v0.4.0.
Since then, we’ve made several stabilizing improvements to the server
and introduced a few major features, bringing us closer to completely replacing
our previous Python-based language server, ruff-lsp
.
If you want to get started with ruff server
, enable it in Ruff's VS Code extension,
or read the setup guide.
Rewrite it in Rust #
Ruff's editor integrations have always been powered by a language server. Unlike Pylance or Jedi, which are general-purpose language servers for Python, Ruff’s language server facilitates linting, formatting, and automatic fixes within editors, like VS Code or Neovim.
In December 2022, we introduced ruff-lsp
, a language server written in Python that interfaced with
Ruff over the command line.
While ruff-lsp
worked well for a time, we ran into fundamental technical limitations that made it
difficult to maintain and extend:
ruff-lsp
was developed, tested, and released independently of Ruff, which meant we needed to maintain compatibility with a wide range of Ruff versions.- Since
ruff-lsp
interacted with Ruff's command line interface, every new feature had to be exposed in user-facing options, and all data necessary to power the integration had to passed over standard input and output. - Repeatedly running Ruff as a stateless subprocess resulted in unnecessary overhead for each request.
- Since every invocation of Ruff was a separate process, we couldn't implement LSP features that required tracking state across multiple requests (e.g., files that have been modified in the editor but not saved to disk), since Ruff itself was being used in a stateless manner.
We realized that our language server needed to be tightly integrated with Ruff itself if we wanted it to keep up with Ruff’s rapid growth.
That's where ruff server
comes in: a language server written in Rust and built into Ruff.
Like ruff-lsp
, it provides linting, formatting, and other features to our VS Code extension and
editor integrations. But unlike ruff-lsp
, ruff server
uses Ruff directly, as a library, which
makes integration easier (and more performant!) compared to ruff-lsp. Since it's part of
Ruff itself, there's no external package to install.
Ultimately, ruff server
gives us the foundation we need to build a more powerful and feature-rich
editor integration, while delivering significant performance improvements and a more streamlined
installation experience to users in the process.
Features #
ruff server
supports all the features you know and love from ruff-lsp
, while also introducing
a few new ones. Thanks to an extensible architecture, we have many more features planned down the road.
Diagnostic Highlighting #
Ruff will show you rule violations and syntax errors as fast as you can type.
Dynamic Configuration #
Ruff dynamically refreshes diagnostics when you update your configuration.
Formatting #
Ruff can format your code instantly.
Code Actions #
Ruff can solve issues with your code in seconds using Code Actions.
You can also chose to ignore diagnostics entirely with noqa
comments.
Source Actions #
Ruff provides source actions and commands to re-format code or solve issues across an entire file.
You can even run these actions on-save. For example, to format on-save in VS Code, add the following
to your settings.json
:
{
"[python]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "charliermarsh.ruff"
}
}
On save, Ruff will format your code automatically.
Hover Hints #
Ruff can show you the documentation for # noqa
codes.
Jupyter Notebook #
ruff server
fully supports Jupyter Notebook files. We even support range formatting within
Notebook cells.
What’s next #
We’re really excited about the future of ruff server
. Here's what's coming next:
- Supporting more editors: Currently, we support VS Code, Neovim, and Helix. At a minimum, we plan to support all of the editors that
ruff-lsp
officially supports. But expect us to go beyond that. - Deprecating
ruff-lsp
:ruff server
will be a drop-in upgrade forruff-lsp
. We plan to deprecate and, eventually, archive the old language server. - Supporting future Ruff features: Future Ruff CLI features will have corresponding support in the language server.
- Supporting more general language server features: We plan to expand the server's capabilities beyond linting, formatting, and diagnostics.
Overall, our goal with ruff server
is to build the best, most feature-rich Python language server available. This release marks an important milestone in reaching that goal.