Skip to content

Commit 0c80c56

Browse files
[syntax-errors] Use consistent message for bad starred expression usage. (#17772)
1 parent b7ce694 commit 0c80c56

9 files changed

+15
-15
lines changed

crates/ruff_python_parser/src/semantic_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ impl Display for SemanticSyntaxError {
941941
write!(f, "name `{name}` is used prior to global declaration")
942942
}
943943
SemanticSyntaxErrorKind::InvalidStarExpression => {
944-
f.write_str("can't use starred expression here")
944+
f.write_str("Starred expression cannot be used here")
945945
}
946946
SemanticSyntaxErrorKind::AsyncComprehensionInSyncComprehension(python_version) => {
947947
write!(

crates/ruff_python_parser/tests/snapshots/invalid_syntax@assign_stmt_starred_expr_value.py.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ Module(
165165

166166
|
167167
1 | _ = *[42]
168-
| ^^^^^ Syntax Error: can't use starred expression here
168+
| ^^^^^ Syntax Error: Starred expression cannot be used here
169169
2 | _ = *{42}
170170
3 | _ = *list()
171171
|
@@ -174,7 +174,7 @@ Module(
174174
|
175175
1 | _ = *[42]
176176
2 | _ = *{42}
177-
| ^^^^^ Syntax Error: can't use starred expression here
177+
| ^^^^^ Syntax Error: Starred expression cannot be used here
178178
3 | _ = *list()
179179
4 | _ = *(p + q)
180180
|
@@ -184,7 +184,7 @@ Module(
184184
1 | _ = *[42]
185185
2 | _ = *{42}
186186
3 | _ = *list()
187-
| ^^^^^^^ Syntax Error: can't use starred expression here
187+
| ^^^^^^^ Syntax Error: Starred expression cannot be used here
188188
4 | _ = *(p + q)
189189
|
190190

@@ -193,5 +193,5 @@ Module(
193193
2 | _ = *{42}
194194
3 | _ = *list()
195195
4 | _ = *(p + q)
196-
| ^^^^^^^^ Syntax Error: can't use starred expression here
196+
| ^^^^^^^^ Syntax Error: Starred expression cannot be used here
197197
|

crates/ruff_python_parser/tests/snapshots/invalid_syntax@expressions__yield__star_expression.py.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Module(
118118
|
119119
1 | # Cannot use starred expression here
120120
2 | yield (*x)
121-
| ^^ Syntax Error: can't use starred expression here
121+
| ^^ Syntax Error: Starred expression cannot be used here
122122
3 |
123123
4 | yield *x and y, z
124124
|

crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_iter_expr.py.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ Module(
187187

188188
|
189189
1 | for x in *a and b: ...
190-
| ^^^^^^^^ Syntax Error: can't use starred expression here
190+
| ^^^^^^^^ Syntax Error: Starred expression cannot be used here
191191
2 | for x in yield a: ...
192192
3 | for target in x := 1: ...
193193
|

crates/ruff_python_parser/tests/snapshots/invalid_syntax@for_stmt_invalid_target.py.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ Module(
469469
1 | for 1 in x: ...
470470
2 | for "a" in x: ...
471471
3 | for *x and y in z: ...
472-
| ^^^^^^^^ Syntax Error: can't use starred expression here
472+
| ^^^^^^^^ Syntax Error: Starred expression cannot be used here
473473
4 | for *x | y in z: ...
474474
5 | for await x in z: ...
475475
|
@@ -479,7 +479,7 @@ Module(
479479
2 | for "a" in x: ...
480480
3 | for *x and y in z: ...
481481
4 | for *x | y in z: ...
482-
| ^^^^^^ Syntax Error: can't use starred expression here
482+
| ^^^^^^ Syntax Error: Starred expression cannot be used here
483483
5 | for await x in z: ...
484484
6 | for yield x in y: ...
485485
|

crates/ruff_python_parser/tests/snapshots/invalid_syntax@return_stmt_invalid_expr.py.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Module(
186186

187187
|
188188
1 | return *
189-
| ^ Syntax Error: can't use starred expression here
189+
| ^ Syntax Error: Starred expression cannot be used here
190190
2 | return yield x
191191
3 | return yield from x
192192
|
@@ -196,5 +196,5 @@ Module(
196196
3 | return yield from x
197197
4 | return x := 1
198198
5 | return *x and y
199-
| ^^^^^^^^ Syntax Error: can't use starred expression here
199+
| ^^^^^^^^ Syntax Error: Starred expression cannot be used here
200200
|

crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_for.py.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ Module(
9595

9696
|
9797
1 | for _ in *x: ...
98-
| ^^ Syntax Error: can't use starred expression here
98+
| ^^ Syntax Error: Starred expression cannot be used here
9999
2 | for *x in xs: ...
100100
|
101101

102102

103103
|
104104
1 | for _ in *x: ...
105105
2 | for *x in xs: ...
106-
| ^^ Syntax Error: can't use starred expression here
106+
| ^^ Syntax Error: Starred expression cannot be used here
107107
|

crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_return.py.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ Module(
6060

6161
|
6262
1 | def f(): return *x
63-
| ^^ Syntax Error: can't use starred expression here
63+
| ^^ Syntax Error: Starred expression cannot be used here
6464
|

crates/ruff_python_parser/tests/snapshots/invalid_syntax@single_star_yield.py.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ Module(
6565

6666
|
6767
1 | def f(): yield *x
68-
| ^^ Syntax Error: can't use starred expression here
68+
| ^^ Syntax Error: Starred expression cannot be used here
6969
|

0 commit comments

Comments
 (0)