Add support for PEP 701 (#7376)

## Summary

This PR adds support for PEP 701 in Ruff. This is a rollup PR of all the
other individual PRs. The separate PRs were created for logic separation
and code reviews. Refer to each pull request for a detail description on
the change.

Refer to the PR description for the list of pull requests within this PR.

## Test Plan

### Formatter ecosystem checks

Explanation for the change in ecosystem check:
https://github.com/astral-sh/ruff/pull/7597#issue-1908878183

#### `main`

```
| project      | similarity index  | total files       | changed files     |
|--------------|------------------:|------------------:|------------------:|
| cpython      |           0.76083 |              1789 |              1631 |
| django       |           0.99983 |              2760 |                36 |
| transformers |           0.99963 |              2587 |               319 |
| twine        |           1.00000 |                33 |                 0 |
| typeshed     |           0.99983 |              3496 |                18 |
| warehouse    |           0.99967 |               648 |                15 |
| zulip        |           0.99972 |              1437 |                21 |
```

#### `dhruv/pep-701`

```
| project      | similarity index  | total files       | changed files     |
|--------------|------------------:|------------------:|------------------:|
| cpython      |           0.76051 |              1789 |              1632 |
| django       |           0.99983 |              2760 |                36 |
| transformers |           0.99963 |              2587 |               319 |
| twine        |           1.00000 |                33 |                 0 |
| typeshed     |           0.99983 |              3496 |                18 |
| warehouse    |           0.99967 |               648 |                15 |
| zulip        |           0.99972 |              1437 |                21 |
```
This commit is contained in:
Dhruv Manilawala 2023-09-29 08:25:39 +05:30 committed by GitHub
parent 78b8741352
commit e62e245c61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
115 changed files with 44780 additions and 31370 deletions

View file

@ -0,0 +1,66 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
FStringEnd,
2..3,
),
(
String {
value: "",
kind: String,
triple_quoted: false,
},
4..6,
),
(
FStringStart,
7..9,
),
(
FStringEnd,
9..10,
),
(
FStringStart,
11..13,
),
(
FStringEnd,
13..14,
),
(
String {
value: "",
kind: String,
triple_quoted: false,
},
15..17,
),
(
FStringStart,
18..22,
),
(
FStringEnd,
22..25,
),
(
FStringStart,
26..30,
),
(
FStringEnd,
30..33,
),
(
Newline,
33..33,
),
]

View file

@ -0,0 +1,88 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
FStringMiddle {
value: "normal ",
is_raw: false,
},
2..9,
),
(
Lbrace,
9..10,
),
(
Name {
name: "foo",
},
10..13,
),
(
Rbrace,
13..14,
),
(
FStringMiddle {
value: " {another} ",
is_raw: false,
},
14..27,
),
(
Lbrace,
27..28,
),
(
Name {
name: "bar",
},
28..31,
),
(
Rbrace,
31..32,
),
(
FStringMiddle {
value: " {",
is_raw: false,
},
32..35,
),
(
Lbrace,
35..36,
),
(
Name {
name: "three",
},
36..41,
),
(
Rbrace,
41..42,
),
(
FStringMiddle {
value: "}",
is_raw: false,
},
42..44,
),
(
FStringEnd,
44..45,
),
(
Newline,
45..45,
),
]

View file

@ -0,0 +1,60 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..4,
),
(
FStringMiddle {
value: "\n# not a comment ",
is_raw: false,
},
4..21,
),
(
Lbrace,
21..22,
),
(
Comment(
"# comment {",
),
23..34,
),
(
NonLogicalNewline,
34..35,
),
(
Name {
name: "x",
},
39..40,
),
(
NonLogicalNewline,
40..41,
),
(
Rbrace,
41..42,
),
(
FStringMiddle {
value: " # not a comment\n",
is_raw: false,
},
42..59,
),
(
FStringEnd,
59..62,
),
(
Newline,
62..62,
),
]

View file

@ -0,0 +1,116 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
Lbrace,
2..3,
),
(
Name {
name: "x",
},
3..4,
),
(
Exclamation,
4..5,
),
(
Name {
name: "s",
},
5..6,
),
(
Rbrace,
6..7,
),
(
FStringMiddle {
value: " ",
is_raw: false,
},
7..8,
),
(
Lbrace,
8..9,
),
(
Name {
name: "x",
},
9..10,
),
(
Equal,
10..11,
),
(
Exclamation,
11..12,
),
(
Name {
name: "r",
},
12..13,
),
(
Rbrace,
13..14,
),
(
FStringMiddle {
value: " ",
is_raw: false,
},
14..15,
),
(
Lbrace,
15..16,
),
(
Name {
name: "x",
},
16..17,
),
(
Colon,
17..18,
),
(
FStringMiddle {
value: ".3f!r",
is_raw: false,
},
18..23,
),
(
Rbrace,
23..24,
),
(
FStringMiddle {
value: " {x!r}",
is_raw: false,
},
24..32,
),
(
FStringEnd,
32..33,
),
(
Newline,
33..33,
),
]

View file

@ -0,0 +1,71 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
FStringMiddle {
value: "\\",
is_raw: false,
},
2..3,
),
(
Lbrace,
3..4,
),
(
Name {
name: "x",
},
4..5,
),
(
Colon,
5..6,
),
(
FStringMiddle {
value: "\\\"\\",
is_raw: false,
},
6..9,
),
(
Lbrace,
9..10,
),
(
Name {
name: "x",
},
10..11,
),
(
Rbrace,
11..12,
),
(
Rbrace,
12..13,
),
(
FStringMiddle {
value: " \\\"\\\"\\\n end",
is_raw: false,
},
13..24,
),
(
FStringEnd,
24..25,
),
(
Newline,
25..25,
),
]

View file

@ -0,0 +1,98 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
FStringMiddle {
value: "\\",
is_raw: false,
},
2..3,
),
(
Lbrace,
3..4,
),
(
Name {
name: "foo",
},
4..7,
),
(
Rbrace,
7..8,
),
(
FStringEnd,
8..9,
),
(
FStringStart,
10..12,
),
(
FStringMiddle {
value: "\\\\",
is_raw: false,
},
12..14,
),
(
Lbrace,
14..15,
),
(
Name {
name: "foo",
},
15..18,
),
(
Rbrace,
18..19,
),
(
FStringEnd,
19..20,
),
(
FStringStart,
21..23,
),
(
FStringMiddle {
value: "\\{foo}",
is_raw: false,
},
23..31,
),
(
FStringEnd,
31..32,
),
(
FStringStart,
33..35,
),
(
FStringMiddle {
value: "\\\\{foo}",
is_raw: false,
},
35..44,
),
(
FStringEnd,
44..45,
),
(
Newline,
45..45,
),
]

View file

@ -0,0 +1,71 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..3,
),
(
FStringMiddle {
value: "\\",
is_raw: true,
},
3..4,
),
(
Lbrace,
4..5,
),
(
Name {
name: "x",
},
5..6,
),
(
Colon,
6..7,
),
(
FStringMiddle {
value: "\\\"\\",
is_raw: true,
},
7..10,
),
(
Lbrace,
10..11,
),
(
Name {
name: "x",
},
11..12,
),
(
Rbrace,
12..13,
),
(
Rbrace,
13..14,
),
(
FStringMiddle {
value: " \\\"\\\"\\\n end",
is_raw: true,
},
14..25,
),
(
FStringEnd,
25..26,
),
(
Newline,
26..26,
),
]

View file

@ -0,0 +1,72 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
FStringMiddle {
value: "first ",
is_raw: false,
},
2..8,
),
(
Lbrace,
8..9,
),
(
NonLogicalNewline,
9..10,
),
(
Name {
name: "x",
},
14..15,
),
(
NonLogicalNewline,
15..16,
),
(
Star,
24..25,
),
(
NonLogicalNewline,
25..26,
),
(
Name {
name: "y",
},
38..39,
),
(
NonLogicalNewline,
39..40,
),
(
Rbrace,
40..41,
),
(
FStringMiddle {
value: " second",
is_raw: false,
},
41..48,
),
(
FStringEnd,
48..49,
),
(
Newline,
49..49,
),
]

View file

@ -0,0 +1,99 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..4,
),
(
FStringMiddle {
value: "\nhello\n world\n",
is_raw: false,
},
4..21,
),
(
FStringEnd,
21..24,
),
(
FStringStart,
25..29,
),
(
FStringMiddle {
value: "\n world\nhello\n",
is_raw: false,
},
29..46,
),
(
FStringEnd,
46..49,
),
(
FStringStart,
50..52,
),
(
FStringMiddle {
value: "some ",
is_raw: false,
},
52..57,
),
(
Lbrace,
57..58,
),
(
FStringStart,
58..62,
),
(
FStringMiddle {
value: "multiline\nallowed ",
is_raw: false,
},
62..80,
),
(
Lbrace,
80..81,
),
(
Name {
name: "x",
},
81..82,
),
(
Rbrace,
82..83,
),
(
FStringEnd,
83..86,
),
(
Rbrace,
86..87,
),
(
FStringMiddle {
value: " string",
is_raw: false,
},
87..94,
),
(
FStringEnd,
94..95,
),
(
Newline,
95..95,
),
]

View file

@ -0,0 +1,25 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
FStringMiddle {
value: "\\N{BULLET} normal \\Nope \\N",
is_raw: false,
},
2..28,
),
(
FStringEnd,
28..29,
),
(
Newline,
29..29,
),
]

View file

@ -0,0 +1,46 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..3,
),
(
FStringMiddle {
value: "\\N",
is_raw: true,
},
3..5,
),
(
Lbrace,
5..6,
),
(
Name {
name: "BULLET",
},
6..12,
),
(
Rbrace,
12..13,
),
(
FStringMiddle {
value: " normal",
is_raw: true,
},
13..20,
),
(
FStringEnd,
20..21,
),
(
Newline,
21..21,
),
]

View file

@ -0,0 +1,163 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
FStringMiddle {
value: "foo ",
is_raw: false,
},
2..6,
),
(
Lbrace,
6..7,
),
(
FStringStart,
7..9,
),
(
FStringMiddle {
value: "bar ",
is_raw: false,
},
9..13,
),
(
Lbrace,
13..14,
),
(
Name {
name: "x",
},
14..15,
),
(
Plus,
16..17,
),
(
FStringStart,
18..20,
),
(
Lbrace,
20..21,
),
(
Name {
name: "wow",
},
21..24,
),
(
Rbrace,
24..25,
),
(
FStringEnd,
25..26,
),
(
Rbrace,
26..27,
),
(
FStringEnd,
27..28,
),
(
Rbrace,
28..29,
),
(
FStringMiddle {
value: " baz",
is_raw: false,
},
29..33,
),
(
FStringEnd,
33..34,
),
(
FStringStart,
35..37,
),
(
FStringMiddle {
value: "foo ",
is_raw: false,
},
37..41,
),
(
Lbrace,
41..42,
),
(
FStringStart,
42..44,
),
(
FStringMiddle {
value: "bar",
is_raw: false,
},
44..47,
),
(
FStringEnd,
47..48,
),
(
Rbrace,
48..49,
),
(
FStringMiddle {
value: " some ",
is_raw: false,
},
49..55,
),
(
Lbrace,
55..56,
),
(
FStringStart,
56..58,
),
(
FStringMiddle {
value: "another",
is_raw: false,
},
58..65,
),
(
FStringEnd,
65..66,
),
(
Rbrace,
66..67,
),
(
FStringEnd,
67..68,
),
(
Newline,
68..68,
),
]

View file

@ -0,0 +1,154 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
Lbrace,
2..3,
),
(
Rbrace,
3..4,
),
(
FStringEnd,
4..5,
),
(
FStringStart,
6..8,
),
(
FStringMiddle {
value: "{}",
is_raw: false,
},
8..12,
),
(
FStringEnd,
12..13,
),
(
FStringStart,
14..16,
),
(
FStringMiddle {
value: " ",
is_raw: false,
},
16..17,
),
(
Lbrace,
17..18,
),
(
Rbrace,
18..19,
),
(
FStringEnd,
19..20,
),
(
FStringStart,
21..23,
),
(
FStringMiddle {
value: "{",
is_raw: false,
},
23..25,
),
(
Lbrace,
25..26,
),
(
Rbrace,
26..27,
),
(
FStringMiddle {
value: "}",
is_raw: false,
},
27..29,
),
(
FStringEnd,
29..30,
),
(
FStringStart,
31..33,
),
(
FStringMiddle {
value: "{{}}",
is_raw: false,
},
33..41,
),
(
FStringEnd,
41..42,
),
(
FStringStart,
43..45,
),
(
FStringMiddle {
value: " ",
is_raw: false,
},
45..46,
),
(
Lbrace,
46..47,
),
(
Rbrace,
47..48,
),
(
FStringMiddle {
value: " {} {",
is_raw: false,
},
48..56,
),
(
Lbrace,
56..57,
),
(
Rbrace,
57..58,
),
(
FStringMiddle {
value: "} {{}} ",
is_raw: false,
},
58..71,
),
(
FStringEnd,
71..72,
),
(
Newline,
72..72,
),
]

View file

@ -0,0 +1,90 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
FStringEnd,
2..3,
),
(
FStringStart,
4..6,
),
(
FStringEnd,
6..7,
),
(
FStringStart,
8..11,
),
(
FStringEnd,
11..12,
),
(
FStringStart,
13..16,
),
(
FStringEnd,
16..17,
),
(
FStringStart,
18..21,
),
(
FStringEnd,
21..22,
),
(
FStringStart,
23..26,
),
(
FStringEnd,
26..27,
),
(
FStringStart,
28..31,
),
(
FStringEnd,
31..32,
),
(
FStringStart,
33..36,
),
(
FStringEnd,
36..37,
),
(
FStringStart,
38..41,
),
(
FStringEnd,
41..42,
),
(
FStringStart,
43..46,
),
(
FStringEnd,
46..47,
),
(
Newline,
47..47,
),
]

View file

@ -0,0 +1,201 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
Lbrace,
2..3,
),
(
Name {
name: "foo",
},
3..6,
),
(
Colon,
6..7,
),
(
Rbrace,
7..8,
),
(
FStringMiddle {
value: " ",
is_raw: false,
},
8..9,
),
(
Lbrace,
9..10,
),
(
Name {
name: "x",
},
10..11,
),
(
Equal,
11..12,
),
(
Exclamation,
12..13,
),
(
Name {
name: "s",
},
13..14,
),
(
Colon,
14..15,
),
(
FStringMiddle {
value: ".3f",
is_raw: false,
},
15..18,
),
(
Rbrace,
18..19,
),
(
FStringMiddle {
value: " ",
is_raw: false,
},
19..20,
),
(
Lbrace,
20..21,
),
(
Name {
name: "x",
},
21..22,
),
(
Colon,
22..23,
),
(
FStringMiddle {
value: ".",
is_raw: false,
},
23..24,
),
(
Lbrace,
24..25,
),
(
Name {
name: "y",
},
25..26,
),
(
Rbrace,
26..27,
),
(
FStringMiddle {
value: "f",
is_raw: false,
},
27..28,
),
(
Rbrace,
28..29,
),
(
FStringMiddle {
value: " ",
is_raw: false,
},
29..30,
),
(
Lbrace,
30..31,
),
(
String {
value: "",
kind: String,
triple_quoted: false,
},
31..33,
),
(
Colon,
33..34,
),
(
FStringMiddle {
value: "*^",
is_raw: false,
},
34..36,
),
(
Lbrace,
36..37,
),
(
Int {
value: 1,
},
37..38,
),
(
Colon,
38..39,
),
(
Lbrace,
39..40,
),
(
Int {
value: 1,
},
40..41,
),
(
Rbrace,
41..42,
),
(
Rbrace,
42..43,
),
(
Rbrace,
43..44,
),
(
FStringEnd,
44..45,
),
(
Newline,
45..45,
),
]

View file

@ -0,0 +1,50 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
FStringMiddle {
value: "foo ",
is_raw: false,
},
2..6,
),
(
Lbrace,
6..7,
),
(
Exclamation,
7..8,
),
(
Name {
name: "pwd",
},
8..11,
),
(
Rbrace,
11..12,
),
(
FStringMiddle {
value: " bar",
is_raw: false,
},
12..16,
),
(
FStringEnd,
16..17,
),
(
Newline,
17..17,
),
]

View file

@ -0,0 +1,110 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
Lbrace,
2..3,
),
(
Lambda,
3..9,
),
(
Name {
name: "x",
},
10..11,
),
(
Colon,
11..12,
),
(
Lbrace,
12..13,
),
(
Name {
name: "x",
},
13..14,
),
(
Rbrace,
14..15,
),
(
Rbrace,
15..16,
),
(
FStringEnd,
16..17,
),
(
Newline,
17..18,
),
(
FStringStart,
18..20,
),
(
Lbrace,
20..21,
),
(
Lpar,
21..22,
),
(
Lambda,
22..28,
),
(
Name {
name: "x",
},
29..30,
),
(
Colon,
30..31,
),
(
Lbrace,
31..32,
),
(
Name {
name: "x",
},
32..33,
),
(
Rbrace,
33..34,
),
(
Rpar,
34..35,
),
(
Rbrace,
35..36,
),
(
FStringEnd,
36..37,
),
(
Newline,
37..37,
),
]

View file

@ -0,0 +1,170 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
Lbrace,
2..3,
),
(
Name {
name: "x",
},
3..4,
),
(
Colon,
4..5,
),
(
FStringMiddle {
value: "=10",
is_raw: false,
},
5..8,
),
(
Rbrace,
8..9,
),
(
FStringMiddle {
value: " ",
is_raw: false,
},
9..10,
),
(
Lbrace,
10..11,
),
(
Lpar,
11..12,
),
(
Name {
name: "x",
},
12..13,
),
(
ColonEqual,
13..15,
),
(
Int {
value: 10,
},
15..17,
),
(
Rpar,
17..18,
),
(
Rbrace,
18..19,
),
(
FStringMiddle {
value: " ",
is_raw: false,
},
19..20,
),
(
Lbrace,
20..21,
),
(
Name {
name: "x",
},
21..22,
),
(
Comma,
22..23,
),
(
Lbrace,
23..24,
),
(
Name {
name: "y",
},
24..25,
),
(
ColonEqual,
25..27,
),
(
Int {
value: 10,
},
27..29,
),
(
Rbrace,
29..30,
),
(
Rbrace,
30..31,
),
(
FStringMiddle {
value: " ",
is_raw: false,
},
31..32,
),
(
Lbrace,
32..33,
),
(
Lsqb,
33..34,
),
(
Name {
name: "x",
},
34..35,
),
(
ColonEqual,
35..37,
),
(
Int {
value: 10,
},
37..39,
),
(
Rsqb,
39..40,
),
(
Rbrace,
40..41,
),
(
FStringEnd,
41..42,
),
(
Newline,
42..42,
),
]

View file

@ -0,0 +1,25 @@
---
source: crates/ruff_python_parser/src/lexer.rs
expression: lex_source(source)
---
[
(
FStringStart,
0..2,
),
(
FStringMiddle {
value: "\\0",
is_raw: false,
},
2..4,
),
(
FStringEnd,
4..5,
),
(
Newline,
5..5,
),
]

View file

@ -0,0 +1,848 @@
---
source: crates/ruff_python_parser/src/parser.rs
expression: parse_ast
---
[
Expr(
StmtExpr {
range: 0..9,
value: FString(
ExprFString {
range: 0..9,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..8,
value: Constant(
ExprConstant {
range: 3..7,
value: Str(
StringConstant {
value: " f",
unicode: false,
implicit_concatenated: false,
},
),
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 10..20,
value: FString(
ExprFString {
range: 10..20,
values: [
FormattedValue(
ExprFormattedValue {
range: 12..19,
value: Name(
ExprName {
range: 13..16,
id: "foo",
ctx: Load,
},
),
debug_text: None,
conversion: Str,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 21..28,
value: FString(
ExprFString {
range: 21..28,
values: [
FormattedValue(
ExprFormattedValue {
range: 23..27,
value: Tuple(
ExprTuple {
range: 24..26,
elts: [
Constant(
ExprConstant {
range: 24..25,
value: Int(
3,
),
},
),
],
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 29..39,
value: FString(
ExprFString {
range: 29..39,
values: [
FormattedValue(
ExprFormattedValue {
range: 31..38,
value: Compare(
ExprCompare {
range: 32..36,
left: Constant(
ExprConstant {
range: 32..33,
value: Int(
3,
),
},
),
ops: [
NotEq,
],
comparators: [
Constant(
ExprConstant {
range: 35..36,
value: Int(
4,
),
},
),
],
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 37..37,
values: [],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 40..55,
value: FString(
ExprFString {
range: 40..55,
values: [
FormattedValue(
ExprFormattedValue {
range: 42..54,
value: Constant(
ExprConstant {
range: 43..44,
value: Int(
3,
),
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 45..53,
values: [
FormattedValue(
ExprFormattedValue {
range: 45..50,
value: Constant(
ExprConstant {
range: 46..49,
value: Str(
StringConstant {
value: "}",
unicode: false,
implicit_concatenated: false,
},
),
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 50..53,
value: Str(
StringConstant {
value: ">10",
unicode: false,
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 56..71,
value: FString(
ExprFString {
range: 56..71,
values: [
FormattedValue(
ExprFormattedValue {
range: 58..70,
value: Constant(
ExprConstant {
range: 59..60,
value: Int(
3,
),
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 61..69,
values: [
FormattedValue(
ExprFormattedValue {
range: 61..66,
value: Constant(
ExprConstant {
range: 62..65,
value: Str(
StringConstant {
value: "{",
unicode: false,
implicit_concatenated: false,
},
),
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 66..69,
value: Str(
StringConstant {
value: ">10",
unicode: false,
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 72..86,
value: FString(
ExprFString {
range: 72..86,
values: [
FormattedValue(
ExprFormattedValue {
range: 74..85,
value: Name(
ExprName {
range: 77..80,
id: "foo",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: " ",
trailing: " = ",
},
),
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 87..107,
value: FString(
ExprFString {
range: 87..107,
values: [
FormattedValue(
ExprFormattedValue {
range: 89..106,
value: Name(
ExprName {
range: 92..95,
id: "foo",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: " ",
trailing: " = ",
},
),
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 100..105,
values: [
Constant(
ExprConstant {
range: 100..105,
value: Str(
StringConstant {
value: ".3f ",
unicode: false,
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 108..126,
value: FString(
ExprFString {
range: 108..126,
values: [
FormattedValue(
ExprFormattedValue {
range: 110..125,
value: Name(
ExprName {
range: 113..116,
id: "foo",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: " ",
trailing: " = ",
},
),
conversion: Str,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 127..143,
value: FString(
ExprFString {
range: 127..143,
values: [
FormattedValue(
ExprFormattedValue {
range: 129..142,
value: Tuple(
ExprTuple {
range: 132..136,
elts: [
Constant(
ExprConstant {
range: 132..133,
value: Int(
1,
),
},
),
Constant(
ExprConstant {
range: 135..136,
value: Int(
2,
),
},
),
],
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: " ",
trailing: " = ",
},
),
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 144..170,
value: FString(
ExprFString {
range: 144..170,
values: [
FormattedValue(
ExprFormattedValue {
range: 146..169,
value: FString(
ExprFString {
range: 147..163,
values: [
FormattedValue(
ExprFormattedValue {
range: 149..162,
value: Constant(
ExprConstant {
range: 150..156,
value: Float(
3.1415,
),
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: "=",
},
),
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 158..161,
values: [
Constant(
ExprConstant {
range: 158..161,
value: Str(
StringConstant {
value: ".1f",
unicode: false,
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 164..168,
values: [
Constant(
ExprConstant {
range: 164..168,
value: Str(
StringConstant {
value: "*^20",
unicode: false,
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 172..206,
value: Dict(
ExprDict {
range: 172..206,
keys: [
Some(
FString(
ExprFString {
range: 173..201,
values: [
Constant(
ExprConstant {
range: 174..186,
value: Str(
StringConstant {
value: "foo bar ",
unicode: false,
implicit_concatenated: true,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 186..193,
value: BinOp(
ExprBinOp {
range: 187..192,
left: Name(
ExprName {
range: 187..188,
id: "x",
ctx: Load,
},
),
op: Add,
right: Name(
ExprName {
range: 191..192,
id: "y",
ctx: Load,
},
),
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 193..200,
value: Str(
StringConstant {
value: " baz",
unicode: false,
implicit_concatenated: true,
},
),
},
),
],
implicit_concatenated: true,
},
),
),
],
values: [
Constant(
ExprConstant {
range: 203..205,
value: Int(
10,
),
},
),
],
},
),
},
),
Match(
StmtMatch {
range: 207..269,
subject: Name(
ExprName {
range: 213..216,
id: "foo",
ctx: Load,
},
),
cases: [
MatchCase {
range: 222..269,
pattern: MatchValue(
PatternMatchValue {
range: 227..255,
value: FString(
ExprFString {
range: 227..255,
values: [
Constant(
ExprConstant {
range: 228..240,
value: Str(
StringConstant {
value: "foo bar ",
unicode: false,
implicit_concatenated: true,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 240..247,
value: BinOp(
ExprBinOp {
range: 241..246,
left: Name(
ExprName {
range: 241..242,
id: "x",
ctx: Load,
},
),
op: Add,
right: Name(
ExprName {
range: 245..246,
id: "y",
ctx: Load,
},
),
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 247..254,
value: Str(
StringConstant {
value: " baz",
unicode: false,
implicit_concatenated: true,
},
),
},
),
],
implicit_concatenated: true,
},
),
},
),
guard: None,
body: [
Pass(
StmtPass {
range: 265..269,
},
),
],
},
],
},
),
Expr(
StmtExpr {
range: 271..288,
value: FString(
ExprFString {
range: 271..288,
values: [
Constant(
ExprConstant {
range: 273..274,
value: Str(
StringConstant {
value: "\\",
unicode: false,
implicit_concatenated: false,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 274..279,
value: Name(
ExprName {
range: 275..278,
id: "foo",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 279..280,
value: Str(
StringConstant {
value: "\\",
unicode: false,
implicit_concatenated: false,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 280..287,
value: Name(
ExprName {
range: 281..284,
id: "bar",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 285..286,
values: [
Constant(
ExprConstant {
range: 285..286,
value: Str(
StringConstant {
value: "\\",
unicode: false,
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
},
),
Expr(
StmtExpr {
range: 289..303,
value: FString(
ExprFString {
range: 289..303,
values: [
Constant(
ExprConstant {
range: 291..302,
value: Str(
StringConstant {
value: "\\{foo\\}",
unicode: false,
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),
},
),
]

View file

@ -0,0 +1,214 @@
---
source: crates/ruff_python_parser/src/parser.rs
expression: parse_ast
---
[
Expr(
StmtExpr {
range: 0..29,
value: FString(
ExprFString {
range: 0..29,
values: [
Constant(
ExprConstant {
range: 2..5,
value: Str(
StringConstant {
value: "foo",
unicode: true,
implicit_concatenated: true,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 9..14,
value: Name(
ExprName {
range: 10..13,
id: "bar",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 17..28,
value: Str(
StringConstant {
value: "baz some",
unicode: false,
implicit_concatenated: true,
},
),
},
),
],
implicit_concatenated: true,
},
),
},
),
Expr(
StmtExpr {
range: 30..59,
value: FString(
ExprFString {
range: 30..59,
values: [
Constant(
ExprConstant {
range: 31..34,
value: Str(
StringConstant {
value: "foo",
unicode: false,
implicit_concatenated: true,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 38..43,
value: Name(
ExprName {
range: 39..42,
id: "bar",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 47..58,
value: Str(
StringConstant {
value: "baz some",
unicode: true,
implicit_concatenated: true,
},
),
},
),
],
implicit_concatenated: true,
},
),
},
),
Expr(
StmtExpr {
range: 60..89,
value: FString(
ExprFString {
range: 60..89,
values: [
Constant(
ExprConstant {
range: 61..64,
value: Str(
StringConstant {
value: "foo",
unicode: false,
implicit_concatenated: true,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 68..73,
value: Name(
ExprName {
range: 69..72,
id: "bar",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 76..88,
value: Str(
StringConstant {
value: "baz some",
unicode: false,
implicit_concatenated: true,
},
),
},
),
],
implicit_concatenated: true,
},
),
},
),
Expr(
StmtExpr {
range: 90..128,
value: FString(
ExprFString {
range: 90..128,
values: [
Constant(
ExprConstant {
range: 92..103,
value: Str(
StringConstant {
value: "foobar ",
unicode: true,
implicit_concatenated: true,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 103..108,
value: Name(
ExprName {
range: 104..107,
id: "baz",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 108..127,
value: Str(
StringConstant {
value: " reallybarno",
unicode: false,
implicit_concatenated: true,
},
),
},
),
],
implicit_concatenated: true,
},
),
},
),
]

View file

@ -3,24 +3,37 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..9,
value: Name(
ExprName {
range: 3..7,
id: "user",
ctx: Load,
Expr(
StmtExpr {
range: 0..10,
value: FString(
ExprFString {
range: 0..10,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..9,
value: Name(
ExprName {
range: 3..7,
id: "user",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: "=",
},
),
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: "=",
},
),
conversion: None,
format_spec: None,
},
),
]

View file

@ -3,68 +3,81 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
Constant(
ExprConstant {
range: 2..6,
value: Str(
StringConstant {
value: "mix ",
unicode: false,
Expr(
StmtExpr {
range: 0..38,
value: FString(
ExprFString {
range: 0..38,
values: [
Constant(
ExprConstant {
range: 2..6,
value: Str(
StringConstant {
value: "mix ",
unicode: false,
implicit_concatenated: false,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 6..13,
value: Name(
ExprName {
range: 7..11,
id: "user",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: "=",
},
),
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 13..28,
value: Str(
StringConstant {
value: " with text and ",
unicode: false,
implicit_concatenated: false,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 28..37,
value: Name(
ExprName {
range: 29..35,
id: "second",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: "=",
},
),
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 6..13,
value: Name(
ExprName {
range: 7..11,
id: "user",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: "=",
},
),
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 13..28,
value: Str(
StringConstant {
value: " with text and ",
unicode: false,
implicit_concatenated: false,
},
),
},
),
FormattedValue(
ExprFormattedValue {
range: 28..37,
value: Name(
ExprName {
range: 29..35,
id: "second",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: "=",
},
),
conversion: None,
format_spec: None,
},
),
]

View file

@ -3,44 +3,57 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..13,
value: Name(
ExprName {
range: 3..7,
id: "user",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: "=",
},
),
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 9..12,
values: [
Constant(
ExprConstant {
range: 9..12,
value: Str(
StringConstant {
value: ">10",
unicode: false,
Expr(
StmtExpr {
range: 0..14,
value: FString(
ExprFString {
range: 0..14,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..13,
value: Name(
ExprName {
range: 3..7,
id: "user",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: "=",
},
),
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 9..12,
values: [
Constant(
ExprConstant {
range: 9..12,
value: Str(
StringConstant {
value: ">10",
unicode: false,
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
},
),

View file

@ -1,5 +1,18 @@
---
source: crates/ruff_python_parser/src/string.rs
expression: "parse_fstring(\"\").unwrap()"
expression: "parse_suite(r#\"f\"\"\"#, \"<test>\").unwrap()"
---
[]
[
Expr(
StmtExpr {
range: 0..3,
value: FString(
ExprFString {
range: 0..3,
values: [],
implicit_concatenated: false,
},
),
},
),
]

View file

@ -3,43 +3,56 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..5,
value: Name(
ExprName {
range: 3..4,
id: "a",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
FormattedValue(
ExprFormattedValue {
range: 5..10,
value: Name(
ExprName {
range: 7..8,
id: "b",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 10..17,
value: Str(
StringConstant {
value: "{foo}",
unicode: false,
Expr(
StmtExpr {
range: 0..18,
value: FString(
ExprFString {
range: 0..18,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..5,
value: Name(
ExprName {
range: 3..4,
id: "a",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
FormattedValue(
ExprFormattedValue {
range: 5..10,
value: Name(
ExprName {
range: 7..8,
id: "b",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
Constant(
ExprConstant {
range: 10..17,
value: Str(
StringConstant {
value: "{foo}",
unicode: false,
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),

View file

@ -3,38 +3,51 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..12,
value: Compare(
ExprCompare {
range: 3..11,
left: Constant(
ExprConstant {
range: 3..5,
value: Int(
42,
),
},
),
ops: [
Eq,
],
comparators: [
Constant(
ExprConstant {
range: 9..11,
value: Int(
42,
Expr(
StmtExpr {
range: 0..13,
value: FString(
ExprFString {
range: 0..13,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..12,
value: Compare(
ExprCompare {
range: 3..11,
left: Constant(
ExprConstant {
range: 3..5,
value: Int(
42,
),
},
),
ops: [
Eq,
],
comparators: [
Constant(
ExprConstant {
range: 9..11,
value: Int(
42,
),
},
),
],
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
]

View file

@ -3,47 +3,60 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..15,
value: Name(
ExprName {
range: 3..6,
id: "foo",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 7..14,
values: [
FormattedValue(
ExprFormattedValue {
range: 7..14,
value: Constant(
ExprConstant {
range: 8..13,
value: Str(
StringConstant {
value: "",
unicode: false,
implicit_concatenated: true,
},
),
Expr(
StmtExpr {
range: 0..16,
value: FString(
ExprFString {
range: 0..16,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..15,
value: Name(
ExprName {
range: 3..6,
id: "foo",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 7..14,
values: [
FormattedValue(
ExprFormattedValue {
range: 7..14,
value: Constant(
ExprConstant {
range: 8..13,
value: Str(
StringConstant {
value: "",
unicode: false,
implicit_concatenated: true,
},
),
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
},
),

View file

@ -3,42 +3,55 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..14,
value: Name(
ExprName {
range: 3..6,
id: "foo",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 7..13,
values: [
FormattedValue(
ExprFormattedValue {
range: 7..13,
value: Name(
ExprName {
range: 8..12,
id: "spec",
ctx: Load,
Expr(
StmtExpr {
range: 0..15,
value: FString(
ExprFString {
range: 0..15,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..14,
value: Name(
ExprName {
range: 3..6,
id: "foo",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 7..13,
values: [
FormattedValue(
ExprFormattedValue {
range: 7..13,
value: Name(
ExprName {
range: 8..12,
id: "spec",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
},
),

View file

@ -3,47 +3,60 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..12,
value: Name(
ExprName {
range: 3..6,
id: "foo",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 7..11,
values: [
FormattedValue(
ExprFormattedValue {
range: 7..11,
value: Constant(
ExprConstant {
range: 8..10,
value: Str(
StringConstant {
value: "",
unicode: false,
implicit_concatenated: false,
},
),
Expr(
StmtExpr {
range: 0..13,
value: FString(
ExprFString {
range: 0..13,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..12,
value: Name(
ExprName {
range: 3..6,
id: "foo",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 7..11,
values: [
FormattedValue(
ExprFormattedValue {
range: 7..11,
value: Constant(
ExprConstant {
range: 8..10,
value: Str(
StringConstant {
value: "",
unicode: false,
implicit_concatenated: false,
},
),
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
},
),

View file

@ -3,38 +3,51 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..10,
value: Compare(
ExprCompare {
range: 3..9,
left: Constant(
ExprConstant {
range: 3..4,
value: Int(
1,
),
},
),
ops: [
NotEq,
],
comparators: [
Constant(
ExprConstant {
range: 8..9,
value: Int(
2,
Expr(
StmtExpr {
range: 0..11,
value: FString(
ExprFString {
range: 0..11,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..10,
value: Compare(
ExprCompare {
range: 3..9,
left: Constant(
ExprConstant {
range: 3..4,
value: Int(
1,
),
},
),
ops: [
NotEq,
],
comparators: [
Constant(
ExprConstant {
range: 8..9,
value: Int(
2,
),
},
),
],
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
]

View file

@ -3,39 +3,52 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..12,
value: Name(
ExprName {
range: 3..6,
id: "foo",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 7..11,
values: [
Constant(
ExprConstant {
range: 7..11,
value: Str(
StringConstant {
value: "spec",
unicode: false,
Expr(
StmtExpr {
range: 0..13,
value: FString(
ExprFString {
range: 0..13,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..12,
value: Name(
ExprName {
range: 3..6,
id: "foo",
ctx: Load,
},
),
debug_text: None,
conversion: None,
format_spec: Some(
FString(
ExprFString {
range: 7..11,
values: [
Constant(
ExprConstant {
range: 7..11,
value: Str(
StringConstant {
value: "spec",
unicode: false,
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),
},
),
],
implicit_concatenated: false,
},
),
),
},
),
],
implicit_concatenated: false,
},
),
},
),

View file

@ -3,24 +3,37 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..9,
value: Name(
ExprName {
range: 3..4,
id: "x",
ctx: Load,
Expr(
StmtExpr {
range: 0..10,
value: FString(
ExprFString {
range: 0..10,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..9,
value: Name(
ExprName {
range: 3..4,
id: "x",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: " =",
},
),
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: " =",
},
),
conversion: None,
format_spec: None,
},
),
]

View file

@ -3,24 +3,37 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..9,
value: Name(
ExprName {
range: 3..4,
id: "x",
ctx: Load,
Expr(
StmtExpr {
range: 0..10,
value: FString(
ExprFString {
range: 0..10,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..9,
value: Name(
ExprName {
range: 3..4,
id: "x",
ctx: Load,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: "= ",
},
),
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
debug_text: Some(
DebugText {
leading: "",
trailing: "= ",
},
),
conversion: None,
format_spec: None,
},
),
]

View file

@ -3,18 +3,31 @@ source: crates/ruff_python_parser/src/string.rs
expression: parse_ast
---
[
FormattedValue(
ExprFormattedValue {
range: 2..9,
value: Yield(
ExprYield {
range: 3..8,
value: None,
Expr(
StmtExpr {
range: 0..10,
value: FString(
ExprFString {
range: 0..10,
values: [
FormattedValue(
ExprFormattedValue {
range: 2..9,
value: Yield(
ExprYield {
range: 3..8,
value: None,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
],
implicit_concatenated: false,
},
),
debug_text: None,
conversion: None,
format_spec: None,
},
),
]