---
title: "Ruff v0.16.0 发布：默认规则从59条激增至413条，CI工作流需关注"
source: "Simon Willison 博客（Atom）"
source_tier: "t2"
url: "https://simonwillison.net/2026/Jul/25/ruff/#atom-everything"
permalink: "https://feed.astralor.com/items/itm_4d5da1abe9d0ae45b3c896e2"
published: "2026-07-25T22:44:05.000Z"
score: 84
channel: "tech"
tags: ["Astral","CI/CD","OpenAI","Python","Ruff","代码检查"]
---

# Ruff v0.16.0 发布：默认规则从59条激增至413条，CI工作流需关注

## AI 点评

> 对于 Python 开发者来说，这是一个不容错过的更新信号。Ruff 的默认规则大幅增加意味着我们不能再忽视代码中潜在的问题，而 AI 修复工具正好可以降低升级成本。尤其值得关注的是 Astral（OpenAI）正在将 AI 编码能力与静态分析工具深度整合，这可能是未来工程实践的常态。

## 速览

Ruff Python 代码检查工具发布 v0.16.0，新增413条默认规则（原仅59条），可自动捕获语法错误、运行时错误等严重问题。作者在其三个主要项目（Datasette、sqlite-utils、LLM）上运行后修复了数千个问题，建议开发者使用 `uvx ruff@latest check .` 快速检查，并利用 AI 编码助手（如 Codex、Claude Code）辅助修复。该更新由 OpenAI 旗下 Astral 团队推出，标志着 Python 工程实践的重大演进。

## 关键点

- 默认启用规则数从59条增至413条，覆盖更多严重错误
- 作者使用 `ruff --fix --unsafe-fixes` 批量修复了1538个错误
- 利用 GPT-5.6 和 Claude Opus 5 的 AI 编码助手辅助修复
- 建议开发者立即检查并更新 CI 配置

## 全文

Ruff v0.16.0 Astral shipped a significant new version of their Ruff Python linting tool a few days ago on July 23rd. I noticed today because my various CI jobs all started failing thanks to new default Ruff checks and my unpinned "ruff" dev dependency. From Brent Westbrook's announcement post: Ruff now enables 413 rules by default, up from 59 in previous versions. Since Ruff's default rule set was last modified in v0.1.0, the number of rules in Ruff has grown from 708 to 968. Many of these rules catch severe issues, including syntax errors and immediate runtime errors but were not previously enabled by default. With the new rule set, Ruff will bring these issues and many others to your attention without any Ruff configuration. Here's a one-liner for trying it on any Python project: uvx ruff@latest check . I ran the latest Ruff against my three biggest projects - Datasette, sqlite-utils, and LLM - and it found hundreds of minor issues that breached the new default rules. All three projects have very comprehensive test suites, executed in CI against Python 3.10 through Python 3.14, so upgrades like this are pretty safe. The following command did the bulk of the upgrades: uvx ruff@latest check . --fix --unsafe-fixes Against sqlite-utils, that command reported: Found 1618 errors (1538 fixed, 80 remaining). As an illustrative example, here are three of the remaining issues. Ruff does a nice job of explaining each one: DTZ005 `datetime.datetime.now()` called without a `tz` argument --> tests/test_duplicate.py:17:10 | 15 | "datetime_col" TEXT)""") 16 | # Insert one row of mock data: 17 | dt = datetime.datetime.now() | ^^^^^^^^^^^^^^^^^^^^^^^ 18 | data = { 19 | "text_col": "Cleo", | help: Pass a `datetime.timezone` object to the `tz` parameter BLE001 Do not catch blind exception: `Exception` --> tests/test_plugins.py:16:12 | 14 | db.execute("select * from pragma_function_list()") 15 | return True 16 | except Exception: | ^^^^^^^^^ 17 | return False 18 | finally: | B018 Found useless attribute access. Either assign it to a variable or remove it. --> tests/test_update.py:46:5 | 44 | def test_update_invalid_pk(fresh_db, pk, update_pk): 45 | table = fresh_db["table"] 46 | table.insert({"id1": 5, "id2": 3, "v": 1}, pk=pk).last_pk | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 47 | with pytest.raises(NotFoundError): 48 | table.update(update_pk, {"v": 2}) | Unsurprisingly, given Astral's new home at OpenAI, this output provides everything a coding agent would need to fix the problems. I had Codex (GPT-5.6 Sol high) upgrade LLM and sqlite-utils, and Claude Code (with Opus 5) upgrade Datasette. Tags: python, ruff, astral

---

引用前请核对原文;本文由星际流动整理:https://feed.astralor.com/items/itm_4d5da1abe9d0ae45b3c896e2
