Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# parse_options: {"target-version": "3.10"}
# regression tests for https://github.com/astral-sh/ruff/issues/16874
# starred parameters are fine, just not the annotation
from typing import Annotated, Literal
def foo(*args: Ts): ...
def foo(*x: Literal["this should allow arbitrary strings"]): ...
def foo(*x: Annotated[str, "this should allow arbitrary strings"]): ...
def foo(*args: str, **kwds: int): ...
def union(*x: A | B): ...
21 changes: 17 additions & 4 deletions crates/ruff_python_parser/src/parser/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2959,13 +2959,26 @@ impl<'src> Parser<'src> {
// # parse_options: {"target-version": "3.11"}
// def foo(*args: *Ts): ...

// test_ok param_with_star_annotation_py310
// # parse_options: {"target-version": "3.10"}
// # regression tests for https://github.com/astral-sh/ruff/issues/16874
// # starred parameters are fine, just not the annotation
// from typing import Annotated, Literal
// def foo(*args: Ts): ...
// def foo(*x: Literal["this should allow arbitrary strings"]): ...
// def foo(*x: Annotated[str, "this should allow arbitrary strings"]): ...
// def foo(*args: str, **kwds: int): ...
// def union(*x: A | B): ...

// test_err param_with_star_annotation_py310
// # parse_options: {"target-version": "3.10"}
// def foo(*args: *Ts): ...
self.add_unsupported_syntax_error(
UnsupportedSyntaxErrorKind::StarAnnotation,
parsed_expr.range(),
);
if parsed_expr.is_starred_expr() {
self.add_unsupported_syntax_error(
UnsupportedSyntaxErrorKind::StarAnnotation,
parsed_expr.range(),
);
}

parsed_expr
}
Expand Down
Loading
Loading