mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:22:24 +00:00
Separate terminator token for f-string elements kind (#11842)
## Summary This PR separates the terminator token for f-string elements depending on the context. A list of f-string element can occur either in a regular f-string or a format spec of an f-string. The terminator token is different depending on that context. ## Test Plan `cargo insta test` and verify the updated snapshots.
This commit is contained in:
parent
93973b96cb
commit
a525b4be3d
5 changed files with 73 additions and 44 deletions
|
@ -11,15 +11,15 @@ Module(
|
|||
body: [
|
||||
Expr(
|
||||
StmtExpr {
|
||||
range: 0..14,
|
||||
range: 0..16,
|
||||
value: FString(
|
||||
ExprFString {
|
||||
range: 0..14,
|
||||
range: 0..16,
|
||||
value: FStringValue {
|
||||
inner: Single(
|
||||
FString(
|
||||
FString {
|
||||
range: 0..14,
|
||||
range: 0..16,
|
||||
elements: [
|
||||
Expression(
|
||||
FStringExpressionElement {
|
||||
|
@ -110,17 +110,5 @@ Module(
|
|||
|
||||
|
|
||||
1 | f"{lambda x: x}"
|
||||
| ^ Syntax Error: Expected FStringEnd, found '}'
|
||||
|
|
||||
|
||||
|
||||
|
|
||||
1 | f"{lambda x: x}"
|
||||
| ^ Syntax Error: Expected a statement
|
||||
|
|
||||
|
||||
|
||||
|
|
||||
1 | f"{lambda x: x}"
|
||||
| ^ Syntax Error: Expected a statement
|
||||
| ^ Syntax Error: Expected an f-string element or the end of the f-string
|
||||
|
|
||||
|
|
|
@ -116,7 +116,7 @@ Module(
|
|||
|
||||
|
|
||||
1 | f"hello {x:"
|
||||
| ^ Syntax Error: f-string: expecting '}'
|
||||
| ^ Syntax Error: Expected an f-string element or a '}'
|
||||
2 | f"hello {x:.3f"
|
||||
|
|
||||
|
||||
|
@ -124,7 +124,7 @@ Module(
|
|||
|
|
||||
1 | f"hello {x:"
|
||||
2 | f"hello {x:.3f"
|
||||
| ^ Syntax Error: f-string: expecting '}'
|
||||
| ^ Syntax Error: Expected an f-string element or a '}'
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -335,7 +335,7 @@ Module(
|
|||
4 | 2 + 2
|
||||
5 | f"hello {x:
|
||||
6 | 3 + 3
|
||||
| ^ Syntax Error: Expected an f-string element or the end of the f-string
|
||||
| ^ Syntax Error: Expected an f-string element or a '}'
|
||||
7 | f"hello {x}
|
||||
8 | 4 + 4
|
||||
|
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue