Remove the PREVIEW rule selector (#7389)

The rule selector is not useful because `--select PREVIEW` only targets
Ruff developers and `--ignore PREVIEW` has no effect due to its low
specificity. We may restore it later if useful.
This commit is contained in:
Zanie Blue 2023-09-14 12:31:59 -05:00 committed by GitHub
parent d39eae2713
commit b9bb6bf780
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 65 deletions

View file

@ -588,11 +588,12 @@ impl Configuration {
#[allow(deprecated)]
if matches!(selector, RuleSelector::Nursery) {
let suggestion = if preview.is_disabled() {
"Use the `--preview` flag instead."
" Use the `--preview` flag instead."
} else {
"Use the `PREVIEW` selector instead."
// We have no suggested alternative since there is intentionally no "PREVIEW" selector
""
};
warn_user_once!("The `NURSERY` selector has been deprecated. {suggestion}");
warn_user_once!("The `NURSERY` selector has been deprecated.{suggestion}");
}
if preview.is_disabled() {
@ -1092,6 +1093,27 @@ mod tests {
assert_eq!(actual, expected);
}
#[test]
fn select_all_preview() {
let actual = resolve_rules(
[RuleSelection {
select: Some(vec![RuleSelector::All]),
..RuleSelection::default()
}],
Some(PreviewMode::Disabled),
);
assert!(!actual.intersects(&RuleSet::from_rules(PREVIEW_RULES)));
let actual = resolve_rules(
[RuleSelection {
select: Some(vec![RuleSelector::All]),
..RuleSelection::default()
}],
Some(PreviewMode::Enabled),
);
assert!(actual.intersects(&RuleSet::from_rules(PREVIEW_RULES)));
}
#[test]
fn select_linter_preview() {
let actual = resolve_rules(
@ -1161,31 +1183,6 @@ mod tests {
assert_eq!(actual, expected);
}
#[test]
fn select_preview() {
let actual = resolve_rules(
[RuleSelection {
select: Some(vec![RuleSelector::Preview]),
..RuleSelection::default()
}],
Some(PreviewMode::Disabled),
);
let expected = RuleSet::empty();
assert_eq!(actual, expected);
let actual = resolve_rules(
[RuleSelection {
select: Some(vec![RuleSelector::Preview]),
..RuleSelection::default()
}],
Some(PreviewMode::Enabled),
);
let expected =
RuleSet::from_rules(NURSERY_RULES).union(&RuleSet::from_rules(PREVIEW_RULES));
assert_eq!(actual, expected);
}
#[test]
fn nursery_select_code() {
// Backwards compatible behavior allows selection of nursery rules with their exact code