Ruff 0.16: the default rule set grows from 59 to 413
Translated by a model; the original is in Russian.
Astral has released version 0.16.0 of Ruff, its linter and formatter — a tool for Python written in Rust and capable of replacing a whole set of familiar utilities (Black, Flake8, isort, pydocstyle, pyupgrade and others) while running tens and hundreds of times faster.
More checks out of the box
The main change in this release is the expansion of the rule set enabled by default: there are now 413 of them, up from 59. Since the last time the standard set was revised (version 0.1.0), the total number of rules in Ruff has grown from 708 to 968. Many of them catch serious problems — up to and including syntax errors and errors that immediately cause a failure at runtime — but previously did not run by default. The new set includes, among others, rules from the popular flake8-bugbear and pyupgrade, as well as Ruff's own RUF category.
The authors understand this won't be to everyone's liking: those who want the old behavior back need only specify select = ["E4", "E7", "E9", "F"] in their configuration.
Formatting code in Markdown
Ruff has learned to format Python code blocks embedded in Markdown files. The formatter handles fenced blocks tagged with the languages python, py, pyi, pycon and the like, with pyi treated as a stub file and pycon as a REPL session. The same mechanism also works with Quarto notebook blocks. When needed, formatting can be turned off with the usual fmt: off/fmt: on comments inside a block, or with HTML comments for an entire fragment of a document.
Its own format for suppressing warnings
In addition to the paired ruff: disable/ruff: enable comments introduced in version 0.15, new directives have appeared. The ruff: ignore comment suppresses a diagnostic on the same or the next logical line (much like noqa), while ruff: file-ignore does so throughout the file. A reason-explaining note can be added to each such comment. The new --add-ignore flag places these comments automatically, and in preview mode all directives understand not only codes but also human-readable rule names.
Other changes
The output of the check and format --check commands now shows suggested fixes as a diff by default, and format --check supports the same machine-readable formats (JSON, annotations for GitHub and GitLab) as the linter. There is also a small breaking change: some fields of the JSON output may now contain null instead of their previous default values.
In addition, a dozen rules have been promoted from preview to stable, and the behavior of a number of existing checks has been refined.
Source: Hacker News
Comments
Sign in, to comment.