Skip to content

Commit

Permalink
Error if the NURSERY selector is used with preview
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Jan 29, 2024
1 parent 04000a4 commit 66ccfd3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
9 changes: 3 additions & 6 deletions crates/ruff/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,15 +878,12 @@ fn nursery_group_selector_preview_enabled() {
assert_cmd_snapshot!(cmd
.pass_stdin("I=42\n"), @r###"
success: false
exit_code: 1
exit_code: 2
----- stdout -----
-:1:1: CPY001 Missing copyright notice at top of file
-:1:2: E225 [*] Missing whitespace around operator
Found 2 errors.
[*] 1 fixable with the `--fix` option.
----- stderr -----
warning: The `NURSERY` selector has been deprecated.
ruff failed
Cause: The `NURSERY` selector is deprecated and cannot be used with preview mode enabled.
"###);
}

Expand Down
11 changes: 4 additions & 7 deletions crates/ruff_workspace/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,13 +860,10 @@ impl LintConfiguration {
for (kind, selector) in selection.selectors_by_kind() {
#[allow(deprecated)]
if matches!(selector, RuleSelector::Nursery) {
let suggestion = if preview.mode.is_disabled() {
" Use the `--preview` flag instead."
} else {
// We have no suggested alternative since there is intentionally no "PREVIEW" selector
""
};
warn_user_once!("The `NURSERY` selector has been deprecated.{suggestion}");
if preview.mode.is_enabled() {
return Err(anyhow!("The `NURSERY` selector is deprecated and cannot be used with preview mode enabled."));
}
warn_user_once!("The `NURSERY` selector has been deprecated. Use the `--preview` flag instead.");
};

// Only warn for the following selectors if used to enable rules
Expand Down

0 comments on commit 66ccfd3

Please sign in to comment.