Skip to content

Commit

Permalink
tidy Violation code after split
Browse files Browse the repository at this point in the history
  • Loading branch information
ntBre committed Jan 18, 2025
1 parent 7d616f8 commit c6c434c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> {
match self.type_alias_kind {
TypeAliasKind::TypeAlias | TypeAliasKind::TypeAliasType => {
Some("Use the `type` keyword".to_string())
}
}
Some("Use the `type` keyword".to_string())
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -79,11 +75,7 @@ impl Violation for NonPEP695TypeParameter {
}

fn fix_title(&self) -> Option<String> {
match self.generic_kind {
GenericKind::GenericClass | GenericKind::GenericFunction => {
Some("Use type parameters".to_string())
}
}
Some("Use type parameters".to_string())
}
}

Expand Down

0 comments on commit c6c434c

Please sign in to comment.