mirror of
https://github.com/astral-sh/ruff.git
synced 2026-10-28 10:45:37 +08:00
## Summary This PR introduces clippy-style rule categories that can be used alongside existing linter-based categories in preview. The categories have a lower `specificity` than linter groups, meaning that `select = UP` and `ignore = correctness` will not ignore `UP` correctness rules. In general this leads to more rules being enabled than the alternative we considered where categories and linter groups had equal precedence, which makes it seem like a safer default. We can revisit this if it proves to be unintuitive, or we can add a Cargo-style `priority` field in the worst case. I've tried to organize the commits such that this can be reviewed commit-by-commit and could also be split into multiple PRs. The first two commits update the `ViolationMetadata` macro to allow providing a `category` argument and add such arguments for all rules. This part could be a standalone change without exposing the categories to users but still depends on reaching consensus on all rule categories. The second pair of commits allows using the new categories as selectors alongside existing selectors, including some precedence tests with other selector types. This mostly addresses #1774, but there are some sub-issues there to resolve before closing the issue. ## Test Plan New CLI tests and a new mdtest suite around rule precedence