Skip to content

[syntax-errors] Use consistent message for bad starred expression usage. #17772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
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
2 changes: 1 addition & 1 deletion crates/ruff_python_parser/src/semantic_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ impl Display for SemanticSyntaxError {
write!(f, "name `{name}` is used prior to global declaration")
}
SemanticSyntaxErrorKind::InvalidStarExpression => {
f.write_str("can't use starred expression here")
f.write_str("Starred expression cannot be used here")
}
SemanticSyntaxErrorKind::AsyncComprehensionInSyncComprehension(python_version) => {
write!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Module(

|
1 | _ = *[42]
| ^^^^^ Syntax Error: can't use starred expression here
| ^^^^^ Syntax Error: Starred expression cannot be used here
2 | _ = *{42}
3 | _ = *list()
|
Expand All @@ -174,7 +174,7 @@ Module(
|
1 | _ = *[42]
2 | _ = *{42}
| ^^^^^ Syntax Error: can't use starred expression here
| ^^^^^ Syntax Error: Starred expression cannot be used here
3 | _ = *list()
4 | _ = *(p + q)
|
Expand All @@ -184,7 +184,7 @@ Module(
1 | _ = *[42]
2 | _ = *{42}
3 | _ = *list()
| ^^^^^^^ Syntax Error: can't use starred expression here
| ^^^^^^^ Syntax Error: Starred expression cannot be used here
4 | _ = *(p + q)
|

Expand All @@ -193,5 +193,5 @@ Module(
2 | _ = *{42}
3 | _ = *list()
4 | _ = *(p + q)
| ^^^^^^^^ Syntax Error: can't use starred expression here
| ^^^^^^^^ Syntax Error: Starred expression cannot be used here
|
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Module(
|
1 | # Cannot use starred expression here
2 | yield (*x)
| ^^ Syntax Error: can't use starred expression here
| ^^ Syntax Error: Starred expression cannot be used here
3 |
4 | yield *x and y, z
|
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ Module(

|
1 | for x in *a and b: ...
| ^^^^^^^^ Syntax Error: can't use starred expression here
| ^^^^^^^^ Syntax Error: Starred expression cannot be used here
2 | for x in yield a: ...
3 | for target in x := 1: ...
|
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ Module(
1 | for 1 in x: ...
2 | for "a" in x: ...
3 | for *x and y in z: ...
| ^^^^^^^^ Syntax Error: can't use starred expression here
| ^^^^^^^^ Syntax Error: Starred expression cannot be used here
4 | for *x | y in z: ...
5 | for await x in z: ...
|
Expand All @@ -479,7 +479,7 @@ Module(
2 | for "a" in x: ...
3 | for *x and y in z: ...
4 | for *x | y in z: ...
| ^^^^^^ Syntax Error: can't use starred expression here
| ^^^^^^ Syntax Error: Starred expression cannot be used here
5 | for await x in z: ...
6 | for yield x in y: ...
|
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Module(

|
1 | return *
| ^ Syntax Error: can't use starred expression here
| ^ Syntax Error: Starred expression cannot be used here
2 | return yield x
3 | return yield from x
|
Expand All @@ -196,5 +196,5 @@ Module(
3 | return yield from x
4 | return x := 1
5 | return *x and y
| ^^^^^^^^ Syntax Error: can't use starred expression here
| ^^^^^^^^ Syntax Error: Starred expression cannot be used here
|
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ Module(

|
1 | for _ in *x: ...
| ^^ Syntax Error: can't use starred expression here
| ^^ Syntax Error: Starred expression cannot be used here
2 | for *x in xs: ...
|


|
1 | for _ in *x: ...
2 | for *x in xs: ...
| ^^ Syntax Error: can't use starred expression here
| ^^ Syntax Error: Starred expression cannot be used here
|
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,5 @@ Module(

|
1 | def f(): return *x
| ^^ Syntax Error: can't use starred expression here
| ^^ Syntax Error: Starred expression cannot be used here
|
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ Module(

|
1 | def f(): yield *x
| ^^ Syntax Error: can't use starred expression here
| ^^ Syntax Error: Starred expression cannot be used here
|
Loading