Ignore preview status for fixable and unfixable selectors (#9538)

## Summary

Right now, if you run with `explicit-preview-rules`, and use something
like `select = ["RUF017"]`, we won't actually enable fixing for that
rule, because `fixable = ["ALL"]` (the default) won't include `RUF017`
due to the `explicit-preview-rules`.

The framing in this PR is that `explicit-preview-rules` should only
affect the enablement selectors, whereas the fixable selectors should
just include all possible matching rules. I think this will lead to the
most intuitive behavior.

Closes https://github.com/astral-sh/ruff/issues/9282. (An alternative to
https://github.com/astral-sh/ruff/pull/9284.)
This commit is contained in:
Charlie Marsh 2024-01-15 21:48:41 -05:00 committed by GitHub
parent f9331c7683
commit 9a2f3e2cef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 5 deletions

View file

@ -714,7 +714,7 @@ impl LintConfiguration {
.collect();
// The fixable set keeps track of which rules are fixable.
let mut fixable_set: RuleSet = RuleSelector::All.rules(&preview).collect();
let mut fixable_set: RuleSet = RuleSelector::All.all_rules().collect();
// Ignores normally only subtract from the current set of selected
// rules. By that logic the ignore in `select = [], ignore = ["E501"]`
@ -786,7 +786,7 @@ impl LintConfiguration {
.chain(selection.extend_fixable.iter())
.filter(|s| s.specificity() == spec)
{
for rule in selector.rules(&preview) {
for rule in selector.all_rules() {
fixable_map_updates.insert(rule, true);
}
}
@ -796,7 +796,7 @@ impl LintConfiguration {
.chain(carriedover_unfixables.into_iter().flatten())
.filter(|s| s.specificity() == spec)
{
for rule in selector.rules(&preview) {
for rule in selector.all_rules() {
fixable_map_updates.insert(rule, false);
}
}