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

This commit is contained in:
Abhijeet Prasad Bodas 2025-05-01 23:48:35 +05:30 committed by GitHub
parent b7ce694162
commit 0c80c56afc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 15 additions and 15 deletions

View file

@ -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!(

View file

@ -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()
|
@ -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)
|
@ -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)
|
@ -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
|

View file

@ -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
|

View file

@ -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: ...
|

View file

@ -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: ...
|
@ -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: ...
|

View file

@ -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
|
@ -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
|

View file

@ -95,7 +95,7 @@ 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: ...
|
@ -103,5 +103,5 @@ Module(
|
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
|

View file

@ -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
|

View file

@ -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
|