觉
AI觉醒星球
Awakening is here
Knowledge File / AI技能杠杆
2026-07-26 4 浏览 免费阅读

Ruff v0.16.0

Ruff 发布了 v0.16.0 版本,默认启用规则从 59 条增加到 413 条,许多严重问题现在无需配置即可被检测到。

SOURCE / AI技能杠杆 MIN / 4 ACCESS / 免费阅读 POST / 2026-07-26 06:44:05

原贴

查看原文
作者:Simon Willison 来源站点:simonwillison.net 原贴时间:

原文

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

中文翻译

Ruff v0.16.0 Astral 于 7 月 23 日发布了其 Python 代码检查工具 Ruff 的一个重要新版本。我今天注意到,因为我的各种 CI 作业由于新的默认 Ruff 检查和我未固定版本的 "ruff" 开发依赖而开始失败。来自 Brent Westbrook 的公告:Ruff 现在默认启用 413 条规则,而之前版本是 59 条。由于 Ruff 的默认规则集上次修改是在 v0.1.0,Ruff 中的规则总数从 708 条增长到 968 条。许多这些规则捕获严重问题,包括语法错误和即时运行时错误,但之前并未默认启用。使用新的规则集,Ruff 将在无需任何配置的情况下让您注意到这些问题以及其他许多问题。以下是在任何 Python 项目上尝试的一行命令:uvx ruff@latest check .

核心信息

Ruff 发布了 v0.16.0 版本,默认启用规则从 59 条增加到 413 条,许多严重问题现在无需配置即可被检测到。

  • Ruff 发布了 v0.16.0 版本,默认启用规则从 59 条增加到 413 条,许多严重问题现在无需配置即可被检测到。
  • 原贴提到:Ruff v0.16.0 Astral shipped a significant new version of their Ruff Pyth
  • 来源:simonwillison.net

详细解读

这是什么信号

Ruff v0.16.0 大幅扩展默认规则集,从 59 条增加到 413 条,标志着 Python 代码检查工具走向更严格、更全面的默认配置。Astral 团队(现被 OpenAI 收购)借此推动开发者采用更安全的编码实践,同时展示 Ruff 作为高性能检查工具的持续进化。

为什么重要

默认规则覆盖更多严重错误(如时区缺失、盲目捕获异常、无用属性访问),无需手动配置即可在 CI 中生效。这意味着许多 Python 项目(尤其是未固定版本依赖的项目)会在升级后突然遭遇大量新错误,如 Simon Willison 的三个项目各发现数百个问题。这既提升了代码质量门槛,也迫使开发者适应快速演进的工具生态。

对谁有价值

对 Python 开发者:能更早发现隐藏的 bug 和不良实践,减少线上事故;对开源项目维护者:自动化检查可强化代码合规性,但需额外投入修复;对企业团队:推动统一代码标准,但需评估 CI 中断风险。

可以怎么行动

1. 运行 uvx ruff@latest check . --fix --unsafe-fixes 以自动修复大部分问题。2. 在 pyproject.toml 中固定 Ruff 版本(如 ruff = ">=0.16.0,<0.17.0")避免意外中断。3. 审查剩余错误(如 DTZ005、BLE001、B018),按需添加例外或修改代码。4. 利用 Ruff 的错误解释和 AI 编码助手(如 Codex、Claude Code)批量修复。

风险或限制

部分修复可能改变行为(如 unsafe-fixes),需配合完整测试;新规则可能误报,需手动降级或忽略;对于大型项目,一次性修复数百个错误可能引入回归,建议渐进式采用。

信息差价值

这条内容的真正价值,不只是“有人发布了一个新功能”,而是它揭示了 simonwillison.net 背后的产品方向、工作流变化或竞争信号。对 OPC 来说,这种信息可以转化成持续追踪的栏目选题。

如果把《Ruff v0.16.0》放到你的内容系统里,它最大的价值在于帮助读者更快看懂“为什么值得关注”,而不是只看到一条碎片化动态。

参考来源

AI SUMMARY

这篇文章回答了什么

Ruff v0.16.0主要讲什么?

Ruff 发布了 v0.16.0 版本,默认启用规则从 59 条增加到 413 条,许多严重问题现在无需配置即可被检测到。

这篇文章最值得关注的要点是什么?

Ruff 发布了 v0.16.0 版本,默认启用规则从 59 条增加到 413 条,许多严重问题现在无需配置即可被检测到。;原贴提到:Ruff v0.16.0 Astral shipped a significant new version of their Ruff Pyth;来源:simonwillison.net

这篇文章和哪些AI专题相关?

它适合放在Agent工作流、AI工具、AI超级个体专题里阅读。 关联原因:这篇内容命中「Agent、工作流」等主题信号。;这篇内容命中「自动化」等主题信号。;这篇内容命中「技能」等主题信号。

阅读这篇文章建议先理解哪些关键词?

建议先理解AI工具、工具、自动化、模型、Cursor这些关键词,再结合正文判断工具、机会或风险是否值得进入自己的工作流。

上一篇 Codex 并行 QA 发现复杂行为问题 下一篇 我们将@covacut和@davis7聚集在一起,实时用Codex和他们的Codex Micro键盘构建一个项目