diff --git a/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP014.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP014.py index 83f4d0727b4a4b..a30c8ee39c6713 100644 --- a/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP014.py +++ b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP014.py @@ -23,3 +23,11 @@ MyType = typing.NamedTuple("MyType", [("a", int)], [("b", str)]) MyType = typing.NamedTuple("MyType", [("a", int)], b=str) MyType = typing.NamedTuple(typename="MyType", a=int, b=str) + +# Regression test for: /~https://github.com/astral-sh/ruff/issues/8402#issuecomment-1788787357 +S3File = NamedTuple( + "S3File", + [ + ("dataHPK",* str), + ], +) diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs index 3a8135f93c4bdd..161b63bfa2f77d 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/convert_named_tuple_functional_to_class.rs @@ -181,6 +181,9 @@ fn create_fields_from_fields_arg(fields: &Expr) -> Option> { let [field, annotation] = elts.as_slice() else { return None; }; + if annotation.is_starred_expr() { + return None; + } let ast::ExprStringLiteral { value: field, .. } = field.as_string_literal_expr()?; if !is_identifier(field) { return None;