diff --git a/crates/ruff_linter/src/checkers/ast/analyze/expression.rs b/crates/ruff_linter/src/checkers/ast/analyze/expression.rs index 401d6a7abd85be..b46b4a01af9746 100644 --- a/crates/ruff_linter/src/checkers/ast/analyze/expression.rs +++ b/crates/ruff_linter/src/checkers/ast/analyze/expression.rs @@ -7,9 +7,7 @@ use ruff_python_semantic::analyze::typing; use ruff_text_size::Ranged; use crate::checkers::ast::Checker; -use crate::preview::{ - is_future_required_preview_generics_enabled, is_unnecessary_default_type_args_stubs_enabled, -}; +use crate::preview::is_future_required_preview_generics_enabled; use crate::registry::Rule; use crate::rules::{ airflow, flake8_2020, flake8_async, flake8_bandit, flake8_boolean_trap, flake8_bugbear, @@ -145,8 +143,7 @@ pub(crate) fn expression(expr: &Expr, checker: &Checker) { if checker.is_rule_enabled(Rule::UnnecessaryDefaultTypeArgs) { if checker.target_version() >= PythonVersion::PY313 - || is_unnecessary_default_type_args_stubs_enabled(checker.settings()) - && checker.semantic().in_stub_file() + || checker.semantic().in_stub_file() { pyupgrade::rules::unnecessary_default_type_args(checker, expr); } diff --git a/crates/ruff_linter/src/preview.rs b/crates/ruff_linter/src/preview.rs index cbc0d47b591903..9e0a3f3efb051c 100644 --- a/crates/ruff_linter/src/preview.rs +++ b/crates/ruff_linter/src/preview.rs @@ -201,13 +201,6 @@ pub(crate) const fn is_future_required_preview_generics_enabled(settings: &Linte settings.preview.is_enabled() } -// https://github.com/astral-sh/ruff/pull/20027 -pub(crate) const fn is_unnecessary_default_type_args_stubs_enabled( - settings: &LinterSettings, -) -> bool { - settings.preview.is_enabled() -} - // https://github.com/astral-sh/ruff/pull/20343 pub(crate) const fn is_sim910_expanded_key_support_enabled(settings: &LinterSettings) -> bool { settings.preview.is_enabled() diff --git a/crates/ruff_linter/src/rules/pyupgrade/mod.rs b/crates/ruff_linter/src/rules/pyupgrade/mod.rs index 48012fdf693568..94495523083c02 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/mod.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/mod.rs @@ -439,12 +439,11 @@ mod tests { } #[test] - fn unnecessary_default_type_args_stubs_py312_preview() -> Result<()> { - let snapshot = format!("{}__preview", "UP043.pyi"); + fn unnecessary_default_type_args_stubs_py312() -> Result<()> { + let snapshot = "UP043.pyi"; let diagnostics = test_path( Path::new("pyupgrade/UP043.pyi"), &settings::LinterSettings { - preview: PreviewMode::Enabled, unresolved_target_version: PythonVersion::PY312.into(), ..settings::LinterSettings::for_rule(Rule::UnnecessaryDefaultTypeArgs) }, diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs index c61cee5cb861b4..3fcade60393517 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/unnecessary_default_type_args.rs @@ -8,7 +8,6 @@ use crate::{AlwaysFixableViolation, Applicability, Edit, Fix}; /// ## What it does /// Checks for unnecessary default type arguments for `Generator` and /// `AsyncGenerator` on Python 3.13+. -/// In [preview], this rule will also apply to stub files. /// /// ## Why is this bad? /// Python 3.13 introduced the ability for type parameters to specify default @@ -60,8 +59,6 @@ use crate::{AlwaysFixableViolation, Applicability, Edit, Fix}; /// - [Annotating generators and coroutines](https://docs.python.org/3/library/typing.html#annotating-generators-and-coroutines) /// - [Python documentation: `typing.Generator`](https://docs.python.org/3/library/typing.html#typing.Generator) /// - [Python documentation: `typing.AsyncGenerator`](https://docs.python.org/3/library/typing.html#typing.AsyncGenerator) -/// -/// [preview]: https://docs.astral.sh/ruff/preview/ #[derive(ViolationMetadata)] #[violation_metadata(stable_since = "0.8.0")] pub(crate) struct UnnecessaryDefaultTypeArgs; diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.pyi__preview.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.pyi.snap similarity index 100% rename from crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.pyi__preview.snap rename to crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP043.pyi.snap