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

推荐订阅源

AWS News Blog
AWS News Blog
T
Tenable Blog
Project Zero
Project Zero
T
The Exploit Database - CXSecurity.com
L
LINUX DO - 热门话题
T
Threat Research - Cisco Blogs
T
Threatpost
Security Latest
Security Latest
C
Cisco Blogs
L
Lohrmann on Cybersecurity
S
Security @ Cisco Blogs
Google Online Security Blog
Google Online Security Blog
NISL@THU
NISL@THU
AI
AI
V
Vulnerabilities – Threatpost
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Last Watchdog
The Last Watchdog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
H
Hackread – Cybersecurity News, Data Breaches, AI and More
H
Hacker News: Front Page
U
Unit 42
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MyScale Blog
MyScale Blog
O
OpenAI News
Scott Helme
Scott Helme
V2EX - 技术
V2EX - 技术
P
Proofpoint News Feed
博客园 - 叶小钗
Hugging Face - Blog
Hugging Face - Blog
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Cyberwarzone
Cyberwarzone
博客园 - 【当耐特】
H
Heimdal Security Blog
S
Schneier on Security
阮一峰的网络日志
阮一峰的网络日志
Help Net Security
Help Net Security
D
DataBreaches.Net
Y
Y Combinator Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
TaoSecurity Blog
TaoSecurity Blog
K
Kaspersky official blog
N
News and Events Feed by Topic
WordPress大学
WordPress大学
P
Palo Alto Networks Blog

Blog - Astral

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.5: Ruff's language server is now written in Rust 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 The Ruff Formatter: An extremely fast, Black-compatible Python formatter Ruff v0.1.0 Ruff v0.0.292 Ruff v0.0.285 Ruff v0.0.283 Ruff v0.0.281 Ruff v0.0.278 Ruff v0.0.276 Announcing Astral, the company behind Ruff
Ruff v0.1.5
dhruv@astral · 2023-11-09 · via Blog - Astral

Ruff v0.1.5 is now available with editor support for Jupyter Notebooks. Install it from PyPI, or your package manager of choice:

pip install --upgrade ruff

As a reminder: 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.

View the full changelog on GitHub, or read on for the highlights.

Editor support for Jupyter Notebooks #

Support for Jupyter Notebooks in the Ruff command line interface was stabilized in v0.0.285. Since then, we've been extending the Ruff language server (ruff-lsp) to improve the experience of working with Jupyter Notebooks from within your editor.

The Ruff VS Code extension now offers full support for using Ruff within Jupyter Notebooks. By upgrading to the latest version, Ruff will expose format, lint, and fix actions for individual cells and entire notebooks, with no additional configuration.

Capabilities #

This section showcases various capabilities which are now supported in Jupyter Notebooks, including as diagnostics, code actions, and formatting, along with additional configuration settings for VS Code specifically.

Diagnostics

Diagnostics in notebooks work just like they do in regular Python files: when you open a notebook, any code violations are immediately highlighted in the editor. You can navigate through these issues using editor-specific actions.

View diagnostics

For VS Code users, you can choose to refresh diagnostics either on every keystroke or on save using the ruff.lint.run option.

Code Actions

All existing code actions have been updated to work seamlessly with Jupyter Notebooks.

Moreover, the built-in Ruff commands corresponding to these code actions, such as Ruff: Organize Imports and Ruff: Fix all auto-fixable problems, have been optimized to operate on entire notebooks.

Use code actions

For VS Code users, you can configure Ruff to automatically fix lint violations and organize imports on save for an entire notebook using the following settings:

{
  "notebook.codeActionsOnSave": {
    "source.fixAll.ruff": true,
    "source.organizeImports.ruff": true
  }
}

Additionally, you can execute these code actions on individual cells using the built-in Fix All or Organize Imports commands through the command palette.

Use code actions on single notebook cell

Formatting

Ruff's formatting capabilities are now available for Jupyter Notebooks. You can access these features using commands available in VS Code's command palette.

  • Format Cell: This built-in command formats the currently active cell, which is either the selected cell or the cell where your cursor is located.

Format single notebook cell

  • Ruff: Format Document: This Ruff extension command has been updated to format an entire notebook. Additionally, VS Code provides the Notebook: Format Document command, specifically designed for notebooks.

Format entire notebook

To enable formatting an entire notebook automatically on save, use the following VS Code configuration:

{
  "notebook.formatOnSave.enabled": true,
  "[python]": {
    "editor.defaultFormatter": "charliermarsh.ruff"
  }
}

For further configuration options, refer to the Example configurations section in the extension documentation.

Requirements #

These improvements require the latest Language Server Protocol (LSP) specification (3.17), which includes notebook document support, allowing language servers to provide the same capabilities available for Python files in Jupyter Notebooks.

At time of writing, VS Code is the only compatible option, but we expect other editors to add support in the future.

The latest version of Ruff's VS Code extension includes appropriate versions of Ruff and the ruff-lsp. For other editors, though, you need to ensure you have the supported version of ruff-lsp (0.0.43) and Ruff (v0.1.3 or later), both of which can be installed using your preferred package manager:

pip install "ruff>=0.1.3"
pip install "ruff-lsp>=0.0.43"

Configuration #

When using Ruff through the VS Code extension, there's no need to modify your Ruff configuration. However, if you're using Ruff from the CLI, you'll need to make a few changes to enable Jupyter Notebook support.

Specifically, Ruff's CLI excludes Jupyter Notebook files by default, so you'll need to opt-in by adding the *.ipynb pattern to your extend-include:

[tool.ruff]
extend-include = ["*.ipynb"]

For more details, please refer to the Jupyter Notebook discovery documentation.