ruff/crates/ruff_python_parser/resources/inline/ok
Brent Westbrook ab1011ce70
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / cargo fmt (push) Waiting to run
CI / cargo clippy (push) Blocked by required conditions
CI / test ruff-lsp (push) Blocked by required conditions
CI / cargo test (linux) (push) Blocked by required conditions
CI / cargo test (linux, release) (push) Blocked by required conditions
CI / cargo test (windows) (push) Blocked by required conditions
CI / cargo test (wasm) (push) Blocked by required conditions
CI / cargo build (release) (push) Waiting to run
CI / cargo build (msrv) (push) Blocked by required conditions
CI / cargo fuzz build (push) Blocked by required conditions
CI / fuzz parser (push) Blocked by required conditions
CI / test scripts (push) Blocked by required conditions
CI / formatter instabilities and black similarity (push) Blocked by required conditions
CI / ecosystem (push) Blocked by required conditions
CI / cargo shear (push) Blocked by required conditions
CI / python package (push) Waiting to run
CI / pre-commit (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / check playground (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions
[Knot Playground] Release / publish (push) Waiting to run
[syntax-errors] Single starred assignment target (#17024)
Summary
--

Detects starred assignment targets outside of tuples and lists like `*a
= (1,)`.

This PR only considers assignment statements. I also checked annotated
assigment statements, but these give a separate error that we already
catch, so I think they're okay not to consider:

```pycon
>>> *a: list[int] = []
  File "<python-input-72>", line 1
    *a: list[int] = []
      ^
SyntaxError: invalid syntax
```

Fixes #13759

Test Plan
--

New inline tests, plus a new `SemanticSyntaxError` for an existing
parser test. I also removed a now-invalid case from an otherwise-valid
test fixture.

The new semantic error leads to two errors for the case below:

```python
*foo() = 42
```

but this matches [pyright] too.

[pyright]: https://pyright-play.net/?code=FQMw9mAUCUAEC8sAsAmAUEA
2025-03-29 12:35:47 -04:00
..
ambiguous_lpar_with_items_binary_expr.py
ambiguous_lpar_with_items_if_expr.py
ann_assign_stmt_simple_target.py
args_unparenthesized_generator.py
assign_targets_terminator.py
async_for_statement.py
async_function_definition.py
async_with_statement.py
class_def_arguments.py
class_type_params_py312.py
comma_separated_regular_list_terminator.py
debug_rename_import.py [syntax-errors] Store to or delete __debug__ (#16984) 2025-03-29 12:07:20 -04:00
decorator_async_function.py
decorator_await_expression_py39.py [syntax-errors] Improve error message and range for pre-PEP-614 decorator syntax errors (#16581) 2025-03-17 11:17:27 +00:00
decorator_expression_dotted_ident_py38.py
decorator_expression_eval_hack_py38.py
decorator_expression_identity_hack_py38.py
decorator_expression_py39.py
del_debug_py38.py [syntax-errors] Store to or delete __debug__ (#16984) 2025-03-29 12:07:20 -04:00
del_targets_terminator.py
dotted_name_normalized_spaces.py
except_star_py311.py
except_stmt_as_name_soft_keyword.py
for_in_target_valid_expr.py
for_iter_unpack_py38.py
for_iter_unpack_py39.py
from_import_no_space.py
from_import_soft_keyword_module_name.py
from_import_stmt_terminator.py
fstring_format_spec_terminator.py
function_def_parameter_range.py
function_def_parenthesized_return_types.py
function_def_valid_return_expr.py
function_type_params_py312.py
global_stmt.py
import_as_name_soft_keyword.py
import_stmt_terminator.py
irrefutable_case_pattern_at_end.py [syntax-errors] Irrefutable case pattern before final case (#16905) 2025-03-26 12:27:16 -04:00
iter_unpack_return_py37.py
iter_unpack_return_py38.py
iter_unpack_yield_py37.py
iter_unpack_yield_py38.py
lambda_with_no_parameters.py
lambda_with_valid_body.py
match_after_py310.py
match_as_pattern.py [syntax-errors] Irrefutable case pattern before final case (#16905) 2025-03-26 12:27:16 -04:00
match_as_pattern_soft_keyword.py [syntax-errors] Irrefutable case pattern before final case (#16905) 2025-03-26 12:27:16 -04:00
match_attr_pattern_soft_keyword.py
match_classify_as_identifier_1.py
match_classify_as_identifier_2.py
match_classify_as_keyword_1.py
match_classify_as_keyword_2.py
match_classify_as_keyword_or_identifier.py
match_sequence_pattern_parentheses_terminator.py
match_sequence_pattern_terminator.py [syntax-errors] Irrefutable case pattern before final case (#16905) 2025-03-26 12:27:16 -04:00
match_stmt_subject_expr.py
match_stmt_valid_guard_expr.py
multiple_assignment_in_case_pattern.py [syntax-errors] Multiple assignments in case pattern (#16957) 2025-03-26 13:02:42 -04:00
non_duplicate_type_parameter_names.py [syntax-errors] Duplicate type parameter names (#16858) 2025-03-21 15:06:22 -04:00
non_rebound_comprehension_variable.py [syntax-errors] Start detecting compile-time syntax errors (#16106) 2025-03-21 14:45:25 -04:00
nonlocal_stmt.py
param_with_annotation.py
param_with_default.py
param_with_star_annotation.py
param_with_star_annotation_py310.py [syntax-errors] Fix star annotation before Python 3.11 (#16878) 2025-03-20 17:44:52 -04:00
param_with_star_annotation_py311.py
params_non_default_after_star.py
params_seen_keyword_only_param_after_star.py
parenthesized_context_manager_py39.py [syntax-errors] Parenthesized context managers before Python 3.9 (#16523) 2025-03-17 08:54:55 -04:00
parenthesized_kwarg_py37.py
parenthesized_named_expr_index_py38.py [syntax-errors] Unparenthesized assignment expressions in sets and indexes (#16404) 2025-03-14 15:06:42 -04:00
parenthesized_named_expr_py38.py [syntax-errors] Unparenthesized assignment expressions in sets and indexes (#16404) 2025-03-14 15:06:42 -04:00
parenthesized_star_index_py310.py [syntax-errors] Fix false positive for parenthesized tuple index (#16948) 2025-03-24 10:34:38 -04:00
pep701_f_string_py311.py [syntax-errors] PEP 701 f-strings before Python 3.12 (#16543) 2025-03-18 11:12:15 -04:00
pep701_f_string_py312.py [syntax-errors] PEP 701 f-strings before Python 3.12 (#16543) 2025-03-18 11:12:15 -04:00
pos_only_py38.py
read_from_debug.py [syntax-errors] Store to or delete __debug__ (#16984) 2025-03-29 12:07:20 -04:00
simple_stmts_in_block.py
simple_stmts_with_semicolons.py
single_starred_assignment_target.py [syntax-errors] Single starred assignment target (#17024) 2025-03-29 12:35:47 -04:00
star_index_py311.py
tuple_context_manager_py38.py [syntax-errors] Parenthesized context managers before Python 3.9 (#16523) 2025-03-17 08:54:55 -04:00
type_param_default_py313.py
type_param_param_spec.py
type_param_type_var.py
type_param_type_var_tuple.py
type_stmt_py312.py
unparenthesized_named_expr_index_py39.py [syntax-errors] Unparenthesized assignment expressions in sets and indexes (#16404) 2025-03-14 15:06:42 -04:00
unparenthesized_named_expr_py39.py [syntax-errors] Unparenthesized assignment expressions in sets and indexes (#16404) 2025-03-14 15:06:42 -04:00
walrus_py38.py