Skip to content

Commit 22bc924

Browse files
committed
Rust: Apply Black formatter to annotations.py
1 parent 802c465 commit 22bc924

File tree

1 file changed

+105
-20
lines changed

1 file changed

+105
-20
lines changed

rust/schema/annotations.py

Lines changed: 105 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ class LabelableExpr(Expr):
66
"""
77
The base class for expressions that can be labeled (`LoopExpr`, `ForExpr`, `WhileExpr` or `BlockExpr`).
88
"""
9+
910
label: optional[Label] | child
1011

1112

1213
class LoopingExpr(LabelableExpr):
1314
"""
1415
The base class for expressions that loop (`LoopExpr`, `ForExpr` or `WhileExpr`).
1516
"""
17+
1618
loop_body: optional["BlockExpr"] | child
1719

1820

@@ -21,6 +23,7 @@ class _:
2123
"""
2224
An ADT (Abstract Data Type) definition, such as `Struct`, `Enum`, or `Union`.
2325
"""
26+
2427
derive_macro_expansions: list[MacroItems] | child | rust.detach
2528

2629

@@ -95,8 +98,8 @@ class _:
9598
foo::bar;
9699
```
97100
"""
98-
segment: _ | ql.db_table_name("path_segments_") | doc(
99-
"last segment of this path")
101+
102+
segment: _ | ql.db_table_name("path_segments_") | doc("last segment of this path")
100103

101104

102105
@annotate(GenericArgList)
@@ -132,7 +135,9 @@ class PathExprBase(Expr):
132135
"""
133136

134137

135-
@annotate(PathExpr, replace_bases={Expr: PathExprBase}, add_bases=(PathAstNode,), cfg=True)
138+
@annotate(
139+
PathExpr, replace_bases={Expr: PathExprBase}, add_bases=(PathAstNode,), cfg=True
140+
)
136141
@qltest.test_with(Path)
137142
class _:
138143
"""
@@ -144,6 +149,7 @@ class _:
144149
let z = <TypeRepr as Trait>::foo;
145150
```
146151
"""
152+
147153
path: drop
148154

149155

@@ -195,6 +201,7 @@ class _:
195201
}
196202
```
197203
"""
204+
198205
label: drop
199206

200207

@@ -224,6 +231,7 @@ class _:
224231
};
225232
```
226233
"""
234+
227235
label: drop
228236
loop_body: drop
229237

@@ -297,8 +305,10 @@ class _:
297305
}
298306
```
299307
"""
308+
300309
scrutinee: _ | doc(
301-
"scrutinee (the expression being matched) of this match expression")
310+
"scrutinee (the expression being matched) of this match expression"
311+
)
302312

303313

304314
@annotate(ContinueExpr, cfg=True)
@@ -348,7 +358,7 @@ class _:
348358
0;
349359
};
350360
```
351-
"""
361+
"""
352362

353363

354364
@annotate(ReturnExpr, cfg=True)
@@ -432,6 +442,7 @@ class _:
432442
Foo { a: m, .. } = second;
433443
```
434444
"""
445+
435446
path: drop
436447

437448

@@ -579,6 +590,7 @@ class ArrayExpr(Expr):
579590
[1; 10];
580591
```
581592
"""
593+
582594
exprs: list[Expr] | child
583595
attrs: list[Attr] | child
584596

@@ -591,6 +603,7 @@ class ArrayListExpr(ArrayExpr):
591603
[1, 2, 3];
592604
```
593605
"""
606+
594607
__cfg__ = True
595608

596609

@@ -602,6 +615,7 @@ class ArrayRepeatExpr(ArrayExpr):
602615
[1; 10];
603616
```
604617
"""
618+
605619
__cfg__ = True
606620

607621
repeat_operand: Expr | child
@@ -741,6 +755,7 @@ class _:
741755
}
742756
```
743757
"""
758+
744759
path: drop
745760

746761

@@ -784,6 +799,7 @@ class _:
784799
}
785800
```
786801
"""
802+
787803
path: drop
788804

789805

@@ -831,6 +847,7 @@ class _:
831847
};
832848
```
833849
"""
850+
834851
path: drop
835852

836853

@@ -993,10 +1010,18 @@ class _:
9931010
const X: i32 = 42;
9941011
```
9951012
"""
996-
has_implementation: predicate | doc("this constant has an implementation") | desc("""
1013+
1014+
has_implementation: (
1015+
predicate
1016+
| doc("this constant has an implementation")
1017+
| desc(
1018+
"""
9971019
This is the same as `hasBody` for source code, but for library code (for which we always skip
9981020
the body), this will hold when the body was present in the original code.
999-
""") | rust.detach
1021+
"""
1022+
)
1023+
| rust.detach
1024+
)
10001025

10011026

10021027
@annotate(ConstArg)
@@ -1146,6 +1171,7 @@ class _:
11461171
}
11471172
```
11481173
"""
1174+
11491175
label: drop
11501176
loop_body: drop
11511177

@@ -1162,6 +1188,7 @@ class _:
11621188
```
11631189
"""
11641190

1191+
11651192
@annotate(FormatArgsArg, cfg=True)
11661193
@qltest.test_with(FormatArgsExpr)
11671194
class _:
@@ -1185,6 +1212,7 @@ class _:
11851212
format_args!("{x}, {y}");
11861213
```
11871214
"""
1215+
11881216
formats: list["Format"] | child | synth
11891217

11901218

@@ -1279,6 +1307,7 @@ class _:
12791307
enum E {}
12801308
```
12811309
"""
1310+
12821311
attribute_macro_expansion: optional[MacroItems] | child | rust.detach
12831312

12841313

@@ -1361,6 +1390,7 @@ class _:
13611390
println!("Hello, world!");
13621391
```
13631392
"""
1393+
13641394
macro_call_expansion: optional[AstNode] | child | rust.detach
13651395

13661396

@@ -1414,6 +1444,7 @@ class MacroBlockExpr(Expr):
14141444
my_macro!(); // this macro expands to a sequence of statements (and an expression)
14151445
```
14161446
"""
1447+
14171448
__cfg__ = True
14181449

14191450
statements: list[Stmt] | child
@@ -1530,6 +1561,7 @@ class ParamBase(AstNode):
15301561
"""
15311562
A normal parameter, `Param`, or a self parameter `SelfParam`.
15321563
"""
1564+
15331565
attrs: list["Attr"] | child
15341566
type_repr: optional["TypeRepr"] | child
15351567

@@ -1549,6 +1581,7 @@ class _:
15491581
}
15501582
```
15511583
"""
1584+
15521585
attrs: drop
15531586
type_repr: drop
15541587

@@ -1603,6 +1636,7 @@ class _:
16031636
- `widgets(..)`
16041637
- `<T as Iterator>`
16051638
"""
1639+
16061640
type_repr: optional["TypeRepr"] | child | rust.detach
16071641
trait_type_repr: optional["PathTypeRepr"] | child | rust.detach
16081642

@@ -1777,6 +1811,7 @@ class _:
17771811
}
17781812
```
17791813
"""
1814+
17801815
attrs: drop
17811816
type_repr: drop
17821817

@@ -1835,14 +1870,28 @@ class _:
18351870
// ^^^^^^^^^
18361871
```
18371872
"""
1838-
statements: _ | doc("statements of this statement list") | desc("""
1873+
1874+
statements: (
1875+
_
1876+
| doc("statements of this statement list")
1877+
| desc(
1878+
"""
18391879
The statements of a `StmtList` do not include any tail expression, which
18401880
can be accessed with predicates such as `getTailExpr`.
1841-
""")
1842-
tail_expr: _ | doc("tail expression of this statement list") | desc("""
1881+
"""
1882+
)
1883+
)
1884+
tail_expr: (
1885+
_
1886+
| doc("tail expression of this statement list")
1887+
| desc(
1888+
"""
18431889
The tail expression is the expression at the end of a block, that
18441890
determines the block's value.
1845-
""")
1891+
"""
1892+
)
1893+
)
1894+
18461895

18471896
@annotate(Struct, replace_bases={Item: None}) # still an Item via Adt
18481897
class _:
@@ -1855,6 +1904,7 @@ class _:
18551904
}
18561905
```
18571906
"""
1907+
18581908
field_list: _ | ql.db_table_name("struct_field_lists_")
18591909

18601910

@@ -2152,6 +2202,7 @@ class _:
21522202
}
21532203
```
21542204
"""
2205+
21552206
label: drop
21562207
loop_body: drop
21572208

@@ -2160,10 +2211,17 @@ class _:
21602211
class _:
21612212
param_list: drop
21622213
attrs: drop
2163-
has_implementation: predicate | doc("this function has an implementation") | desc("""
2214+
has_implementation: (
2215+
predicate
2216+
| doc("this function has an implementation")
2217+
| desc(
2218+
"""
21642219
This is the same as `hasBody` for source code, but for library code (for which we always skip
21652220
the body), this will hold when the body was present in the original code.
2166-
""") | rust.detach
2221+
"""
2222+
)
2223+
| rust.detach
2224+
)
21672225

21682226

21692227
@annotate(ClosureExpr, add_bases=[Callable])
@@ -2191,35 +2249,61 @@ class Format(Locatable):
21912249
println!("Value {value:#width$.precision$}");
21922250
```
21932251
"""
2252+
21942253
parent: FormatArgsExpr
21952254
index: int
2196-
argument_ref: optional["FormatArgument"] | child | desc("""
2255+
argument_ref: (
2256+
optional["FormatArgument"]
2257+
| child
2258+
| desc(
2259+
"""
21972260
For example `name` and `0` in:
21982261
```rust
21992262
let name = "Alice";
22002263
println!("{name} in wonderland");
22012264
println!("{0} in wonderland", name);
22022265
```
2203-
""")
2204-
width_argument: optional["FormatArgument"] | child | desc("""
2266+
"""
2267+
)
2268+
)
2269+
width_argument: (
2270+
optional["FormatArgument"]
2271+
| child
2272+
| desc(
2273+
"""
22052274
For example `width` and `1` in:
22062275
```rust
22072276
let width = 6;
22082277
println!("{:width$}", PI);
22092278
println!("{:1$}", PI, width);
22102279
```
2211-
""")
2212-
precision_argument: optional["FormatArgument"] | child | desc("""
2280+
"""
2281+
)
2282+
)
2283+
precision_argument: (
2284+
optional["FormatArgument"]
2285+
| child
2286+
| desc(
2287+
"""
22132288
For example `prec` and `1` in:
22142289
```rust
22152290
let prec = 6;
22162291
println!("{:.prec$}", PI);
22172292
println!("{:.1$}", PI, prec);
22182293
```
2219-
""")
2294+
"""
2295+
)
2296+
)
22202297

22212298

2222-
@synth.on_arguments(parent=FormatArgsExpr, index=int, kind=int, name=string, positional=boolean, offset=int)
2299+
@synth.on_arguments(
2300+
parent=FormatArgsExpr,
2301+
index=int,
2302+
kind=int,
2303+
name=string,
2304+
positional=boolean,
2305+
offset=int,
2306+
)
22232307
@qltest.test_with(FormatArgsExpr)
22242308
class FormatArgument(Locatable):
22252309
"""
@@ -2232,6 +2316,7 @@ class FormatArgument(Locatable):
22322316
println!("Value {0:#1$.2$}", value, width, precision);
22332317
```
22342318
"""
2319+
22352320
parent: Format
22362321
variable: optional[FormatTemplateVariableAccess] | child
22372322

0 commit comments

Comments
 (0)