diff --git a/crates/ruff_linter/src/preview.rs b/crates/ruff_linter/src/preview.rs index 38cae4ae98..3562493e85 100644 --- a/crates/ruff_linter/src/preview.rs +++ b/crates/ruff_linter/src/preview.rs @@ -200,11 +200,6 @@ pub(crate) const fn is_optional_as_none_in_union_enabled(settings: &LinterSettin settings.preview.is_enabled() } -// https://github.com/astral-sh/ruff/pull/18867 -pub(crate) const fn is_raise_exception_byte_string_enabled(settings: &LinterSettings) -> bool { - settings.preview.is_enabled() -} - // https://github.com/astral-sh/ruff/pull/18683 pub(crate) const fn is_safe_super_call_with_parameters_fix_enabled( settings: &LinterSettings, diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/mod.rs b/crates/ruff_linter/src/rules/flake8_errmsg/mod.rs index ffaba36917..c9d452de51 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/mod.rs +++ b/crates/ruff_linter/src/rules/flake8_errmsg/mod.rs @@ -9,7 +9,6 @@ mod tests { use anyhow::Result; use crate::registry::Rule; - use crate::settings::types::PreviewMode; use crate::test::test_path; use crate::{assert_diagnostics, settings}; @@ -47,15 +46,14 @@ mod tests { } #[test] - fn preview_string_exception() -> Result<()> { + fn string_exception() -> Result<()> { let diagnostics = test_path( Path::new("flake8_errmsg/EM101_byte_string.py"), &settings::LinterSettings { - preview: PreviewMode::Enabled, ..settings::LinterSettings::for_rule(Rule::RawStringInException) }, )?; - assert_diagnostics!("preview", diagnostics); + assert_diagnostics!(diagnostics); Ok(()) } } diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs index 62b981b5b8..d5ea4f13fc 100644 --- a/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs +++ b/crates/ruff_linter/src/rules/flake8_errmsg/rules/string_in_exception.rs @@ -7,16 +7,12 @@ use ruff_text_size::Ranged; use crate::Locator; use crate::checkers::ast::Checker; -use crate::preview::is_raise_exception_byte_string_enabled; use crate::registry::Rule; use crate::{Edit, Fix, FixAvailability, Violation}; /// ## What it does /// Checks for the use of string literals in exception constructors. /// -/// In [preview], this rule checks for byte string literals in -/// exception constructors. -/// /// ## Why is this bad? /// Python includes the `raise` in the default traceback (and formatters /// like Rich and IPython do too). @@ -51,8 +47,6 @@ use crate::{Edit, Fix, FixAvailability, Violation}; /// raise RuntimeError(msg) /// RuntimeError: 'Some value' is incorrect /// ``` -/// -/// [preview]: https://docs.astral.sh/ruff/preview/ #[derive(ViolationMetadata)] pub(crate) struct RawStringInException; @@ -218,9 +212,7 @@ pub(crate) fn string_in_exception(checker: &Checker, stmt: &Stmt, exc: &Expr) { // Check for byte string literals. Expr::BytesLiteral(ast::ExprBytesLiteral { value: bytes, .. }) => { if checker.settings().rules.enabled(Rule::RawStringInException) { - if bytes.len() >= checker.settings().flake8_errmsg.max_string_length - && is_raise_exception_byte_string_enabled(checker.settings()) - { + if bytes.len() >= checker.settings().flake8_errmsg.max_string_length { let mut diagnostic = checker.report_diagnostic(RawStringInException, first.range()); if let Some(indentation) = whitespace::indentation(checker.source(), stmt) { diff --git a/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__preview.snap b/crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__string_exception.snap similarity index 100% rename from crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__preview.snap rename to crates/ruff_linter/src/rules/flake8_errmsg/snapshots/ruff_linter__rules__flake8_errmsg__tests__string_exception.snap