From 32684c948895dbc1075632f18d5c3044281c20ef Mon Sep 17 00:00:00 2001 From: InSyncWithFoo Date: Wed, 5 Feb 2025 21:37:44 +0000 Subject: [PATCH] Fix --- .../ruff/rules/class_with_mixed_type_vars.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/crates/ruff_linter/src/rules/ruff/rules/class_with_mixed_type_vars.rs b/crates/ruff_linter/src/rules/ruff/rules/class_with_mixed_type_vars.rs index 02a22cb2df26ad..6750d774d49966 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/class_with_mixed_type_vars.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/class_with_mixed_type_vars.rs @@ -229,14 +229,15 @@ fn generic_arguments_to_type_vars<'a>( /// * It must not be unpacked /// * It must not have any restrictions fn type_var_is_valid(type_var: &TypeVar, unpacked: bool) -> bool { - match (&type_var.kind, unpacked, &type_var.restriction) { - (TypeParamKind::TypeVarTuple, false, _) => false, - (TypeParamKind::TypeVar, true, _) => false, - (TypeParamKind::ParamSpec, true, _) => false, + let is_type_var_tuple = matches!(&type_var.kind, TypeParamKind::TypeVarTuple); - (TypeParamKind::TypeVarTuple, _, Some(_)) => false, - (TypeParamKind::ParamSpec, _, Some(_)) => false, + if is_type_var_tuple && !unpacked || !is_type_var_tuple && unpacked { + return false; + } - _ => true, + if !matches!(&type_var.kind, TypeParamKind::TypeVar) && type_var.restriction.is_some() { + return false; } + + true }