From c6c434cbc75497dbba65caef892801759aeff6d2 Mon Sep 17 00:00:00 2001 From: Brent Westbrook Date: Fri, 17 Jan 2025 22:47:53 -0500 Subject: [PATCH] tidy Violation code after split --- .../pyupgrade/rules/pep695/use_pep695_type_alias.rs | 12 ++---------- .../rules/pep695/use_pep695_type_parameter.rs | 12 ++---------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/use_pep695_type_alias.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/use_pep695_type_alias.rs index faeb425613717..609f632ed14e7 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/use_pep695_type_alias.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/use_pep695_type_alias.rs @@ -73,19 +73,11 @@ impl Violation for NonPEP695TypeAlias { TypeAliasKind::TypeAlias => "`TypeAlias` annotation", TypeAliasKind::TypeAliasType => "`TypeAliasType` assignment", }; - match type_alias_kind { - TypeAliasKind::TypeAlias | TypeAliasKind::TypeAliasType => format!( - "Type alias `{name}` uses {type_alias_method} instead of the `type` keyword" - ), - } + format!("Type alias `{name}` uses {type_alias_method} instead of the `type` keyword") } fn fix_title(&self) -> Option { - match self.type_alias_kind { - TypeAliasKind::TypeAlias | TypeAliasKind::TypeAliasType => { - Some("Use the `type` keyword".to_string()) - } - } + Some("Use the `type` keyword".to_string()) } } diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/use_pep695_type_parameter.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/use_pep695_type_parameter.rs index a802238e34124..c3da1a9105adb 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/use_pep695_type_parameter.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/pep695/use_pep695_type_parameter.rs @@ -64,13 +64,9 @@ impl Violation for NonPEP695TypeParameter { #[derive_message_formats] fn message(&self) -> String { let NonPEP695TypeParameter { name, generic_kind } = self; - let generic_method = match generic_kind { - GenericKind::GenericClass => "`Generic` subclass", - GenericKind::GenericFunction => "Generic function", - }; match generic_kind { GenericKind::GenericClass => { - format!("Generic class `{name}` uses {generic_method} instead of type parameters") + format!("Generic class `{name}` uses `Generic` subclass instead of type parameters") } GenericKind::GenericFunction => { format!("Generic function `{name}` should use type parameters") @@ -79,11 +75,7 @@ impl Violation for NonPEP695TypeParameter { } fn fix_title(&self) -> Option { - match self.generic_kind { - GenericKind::GenericClass | GenericKind::GenericFunction => { - Some("Use type parameters".to_string()) - } - } + Some("Use type parameters".to_string()) } }