惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
Google Developers Blog
S
SegmentFault 最新的问题
Microsoft Security Blog
Microsoft Security Blog
J
Java Code Geeks
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
P
Proofpoint News Feed
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
L
LangChain Blog
F
Fortinet All Blogs
C
Check Point Blog
博客园_首页
I
InfoQ
Jina AI
Jina AI
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
酷 壳 – CoolShell
酷 壳 – CoolShell
Engineering at Meta
Engineering at Meta
美团技术团队
Vercel News
Vercel News
Apple Machine Learning Research
Apple Machine Learning Research

Blog - Astral

Our endorsements for Python’s first Packaging Council Ruff v0.16.0 Vulnerability and malware checks in uv Open source security at Astral Astral to join OpenAI Ruff v0.15.0 ty: An extremely fast Python type checker and language server Python 3.14 Ruff v0.13.0 Astral OSS Fund: One Year Later pyx: a Python-native package registry, now in Beta An experimental, variant-enabled build of uv uv security advisory: ZIP payload obfuscation Ruff v0.12.0 Ruff v0.10.0 Ruff v0.9.0 A new home for python-build-standalone Ruff v0.8.0 Ruff v0.7.0 uv: Unified Python packaging Ruff v0.6.0 Announcing the Astral OSS Fund Ruff v0.5.0 Ruff v0.4.0: a hand-written recursive descent parser for Python Ruff v0.3.0 uv: Python packaging in Rust Ruff v0.2.0 Ruff v0.1.8 Ruff v0.1.5 The Ruff Formatter: An extremely fast, Black-compatible Python formatter
Ruff v0.4.5: Ruff's language server is now written in Rust
jane@astral. · 2024-05-22 · via Blog - Astral

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.

Editing a file in Helix

Dynamic Configuration #

Ruff dynamically refreshes diagnostics when you update your configuration.

Editing a `pyproject.toml` configuration file in VS Code

Formatting #

Ruff can format your code instantly.

Formatting a document in VS Code

Code Actions #

Ruff can solve issues with your code in seconds using Code Actions.

Applying a quick fix in Helix

You can also chose to ignore diagnostics entirely with noqa comments.

Creating a `noqa` comment in VS Code

Source Actions #

Ruff provides source actions and commands to re-format code or solve issues across an entire file.

Using the `source.fixAll` source action in Helix

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.

Formatting on save in VS Code

Hover Hints #

Ruff can show you the documentation for # noqa codes.

Hovering over a noqa code in VS Code

Jupyter Notebook #

ruff server fully supports Jupyter Notebook files. We even support range formatting within Notebook cells.

Editing multiple Jupyter Notebook cells in VS Code

Formatting a selection within a Jupyter Notebook cell in VS Code

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 for ruff-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.