Remove the deprecated E999 rule code (#14428)

This commit is contained in:
Micha Reiser 2024-11-19 13:13:01 +01:00
parent c400725713
commit e9079e7d95
8 changed files with 18 additions and 47 deletions

View file

@ -840,7 +840,7 @@ fn stdin_multiple_parse_error() {
#[test] #[test]
fn parse_error_not_included() { fn parse_error_not_included() {
// Select any rule except for `E999`, syntax error should still be shown. // Parse errors are always shown
let mut cmd = RuffCheck::default().args(["--select=I"]).build(); let mut cmd = RuffCheck::default().args(["--select=I"]).build();
assert_cmd_snapshot!(cmd assert_cmd_snapshot!(cmd
.pass_stdin("foo =\n"), @r" .pass_stdin("foo =\n"), @r"
@ -859,27 +859,6 @@ fn parse_error_not_included() {
"); ");
} }
#[test]
fn deprecated_parse_error_selection() {
let mut cmd = RuffCheck::default().args(["--select=E999"]).build();
assert_cmd_snapshot!(cmd
.pass_stdin("foo =\n"), @r"
success: false
exit_code: 1
----- stdout -----
-:1:6: SyntaxError: Expected an expression
|
1 | foo =
| ^
|
Found 1 error.
----- stderr -----
warning: Rule `E999` is deprecated and will be removed in a future release. Syntax errors will always be shown regardless of whether this rule is selected or not.
");
}
#[test] #[test]
fn full_output_preview() { fn full_output_preview() {
let mut cmd = RuffCheck::default().args(["--preview"]).build(); let mut cmd = RuffCheck::default().args(["--preview"]).build();

View file

@ -88,7 +88,6 @@ linter.rules.enabled = [
ambiguous-class-name (E742), ambiguous-class-name (E742),
ambiguous-function-name (E743), ambiguous-function-name (E743),
io-error (E902), io-error (E902),
syntax-error (E999),
unused-import (F401), unused-import (F401),
import-shadowed-by-loop-var (F402), import-shadowed-by-loop-var (F402),
undefined-local-with-import-star (F403), undefined-local-with-import-star (F403),
@ -150,7 +149,6 @@ linter.rules.should_fix = [
ambiguous-class-name (E742), ambiguous-class-name (E742),
ambiguous-function-name (E743), ambiguous-function-name (E743),
io-error (E902), io-error (E902),
syntax-error (E999),
unused-import (F401), unused-import (F401),
import-shadowed-by-loop-var (F402), import-shadowed-by-loop-var (F402),
undefined-local-with-import-star (F403), undefined-local-with-import-star (F403),

View file

@ -126,7 +126,8 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
(Pycodestyle, "E742") => (RuleGroup::Stable, rules::pycodestyle::rules::AmbiguousClassName), (Pycodestyle, "E742") => (RuleGroup::Stable, rules::pycodestyle::rules::AmbiguousClassName),
(Pycodestyle, "E743") => (RuleGroup::Stable, rules::pycodestyle::rules::AmbiguousFunctionName), (Pycodestyle, "E743") => (RuleGroup::Stable, rules::pycodestyle::rules::AmbiguousFunctionName),
(Pycodestyle, "E902") => (RuleGroup::Stable, rules::pycodestyle::rules::IOError), (Pycodestyle, "E902") => (RuleGroup::Stable, rules::pycodestyle::rules::IOError),
(Pycodestyle, "E999") => (RuleGroup::Deprecated, rules::pycodestyle::rules::SyntaxError), #[allow(deprecated)]
(Pycodestyle, "E999") => (RuleGroup::Removed, rules::pycodestyle::rules::SyntaxError),
// pycodestyle warnings // pycodestyle warnings
(Pycodestyle, "W191") => (RuleGroup::Stable, rules::pycodestyle::rules::TabIndentation), (Pycodestyle, "W191") => (RuleGroup::Stable, rules::pycodestyle::rules::TabIndentation),

View file

@ -39,8 +39,8 @@ impl Violation for IOError {
} }
} }
/// ## Deprecated /// ## Removed
/// This rule has been deprecated and will be removed in a future release. Syntax errors will /// This rule has been removed. Syntax errors will
/// always be shown regardless of whether this rule is selected or not. /// always be shown regardless of whether this rule is selected or not.
/// ///
/// ## What it does /// ## What it does
@ -63,14 +63,16 @@ impl Violation for IOError {
/// ## References /// ## References
/// - [Python documentation: Syntax Errors](https://docs.python.org/3/tutorial/errors.html#syntax-errors) /// - [Python documentation: Syntax Errors](https://docs.python.org/3/tutorial/errors.html#syntax-errors)
#[violation] #[violation]
pub struct SyntaxError { #[deprecated(note = "E999 has been removed")]
pub message: String, pub struct SyntaxError;
}
#[allow(deprecated)]
impl Violation for SyntaxError { impl Violation for SyntaxError {
#[derive_message_formats]
fn message(&self) -> String { fn message(&self) -> String {
let SyntaxError { message } = self; unreachable!("E999 has been removed")
format!("SyntaxError: {message}") }
fn message_formats() -> &'static [&'static str] {
&["SyntaxError"]
} }
} }

View file

@ -1000,13 +1000,9 @@ impl LintConfiguration {
if preview.mode.is_disabled() { if preview.mode.is_disabled() {
for selection in deprecated_selectors.iter().sorted() { for selection in deprecated_selectors.iter().sorted() {
let (prefix, code) = selection.prefix_and_code(); let (prefix, code) = selection.prefix_and_code();
let rule = format!("{prefix}{code}"); warn_user_once_by_message!(
let mut message = "Rule `{prefix}{code}` is deprecated and will be removed in a future release."
format!("Rule `{rule}` is deprecated and will be removed in a future release."); );
if matches!(rule.as_str(), "E999") {
message.push_str(" Syntax errors will always be shown regardless of whether this rule is selected or not.");
}
warn_user_once_by_message!("{message}");
} }
} else { } else {
let deprecated_selectors = deprecated_selectors.iter().sorted().collect::<Vec<_>>(); let deprecated_selectors = deprecated_selectors.iter().sorted().collect::<Vec<_>>();
@ -1632,7 +1628,6 @@ mod tests {
Rule::AmbiguousClassName, Rule::AmbiguousClassName,
Rule::AmbiguousFunctionName, Rule::AmbiguousFunctionName,
Rule::IOError, Rule::IOError,
Rule::SyntaxError,
Rule::TabIndentation, Rule::TabIndentation,
Rule::TrailingWhitespace, Rule::TrailingWhitespace,
Rule::MissingNewlineAtEndOfFile, Rule::MissingNewlineAtEndOfFile,

View file

@ -34,8 +34,7 @@ DEFAULT_TARGETS = [
repo=Repository(owner="bokeh", name="bokeh", ref="branch-3.3"), repo=Repository(owner="bokeh", name="bokeh", ref="branch-3.3"),
check_options=CheckOptions(select="ALL"), check_options=CheckOptions(select="ALL"),
), ),
# Disabled due to use of explicit `select` with `E999`, which is no longer # Disabled due to use of explicit `select` with `E999`, which has been removed.
# supported in `--preview`.
# See: https://github.com/astral-sh/ruff/pull/12129 # See: https://github.com/astral-sh/ruff/pull/12129
# Project( # Project(
# repo=Repository(owner="demisto", name="content", ref="master"), # repo=Repository(owner="demisto", name="content", ref="master"),

2
ruff.schema.json generated
View file

@ -3108,8 +3108,6 @@
"E9", "E9",
"E90", "E90",
"E902", "E902",
"E99",
"E999",
"EM", "EM",
"EM1", "EM1",
"EM10", "EM10",

View file

@ -126,8 +126,7 @@ REPOSITORIES: list[Repository] = [
Repository("binary-husky", "gpt_academic", "master"), Repository("binary-husky", "gpt_academic", "master"),
Repository("bloomberg", "pytest-memray", "main"), Repository("bloomberg", "pytest-memray", "main"),
Repository("bokeh", "bokeh", "branch-3.3", select="ALL"), Repository("bokeh", "bokeh", "branch-3.3", select="ALL"),
# Disabled due to use of explicit `select` with `E999`, which is no longer # Disabled due to use of explicit `select` with `E999`, which has been removed.
# supported in `--preview`.
# See: https://github.com/astral-sh/ruff/pull/12129 # See: https://github.com/astral-sh/ruff/pull/12129
# Repository("demisto", "content", "master"), # Repository("demisto", "content", "master"),
Repository("docker", "docker-py", "main"), Repository("docker", "docker-py", "main"),