Skip to content

Commit 8b59b85

Browse files
committed
Keep a starred var-positional annotation out of the default value error
`def f(*args: *b = (1,))` is invalid syntax, not a var-positional parameter with a default value. Assisted-by: Claude Code:claude-opus-5-5
1 parent 14e5415 commit 8b59b85

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎crates/ruff_python_parser/src/parser/statement.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3631,7 +3631,13 @@ impl<'src> Parser<'src> {
36313631
AllowStarAnnotation::Yes,
36323632
);
36333633

3634-
if parser.at(TokenKind::Equal) {
3634+
// A starred annotation is not an annotation the rule accepts.
3635+
if parser.at(TokenKind::Equal)
3636+
&& !param
3637+
.annotation
3638+
.as_deref()
3639+
.is_some_and(ast::Expr::is_starred_expr)
3640+
{
36353641
// test_err params_var_positional_with_default
36363642
// def foo(a, *args=(1, 2)): ...
36373643
parser.add_error(

0 commit comments

Comments
 (0)