@@ -73,7 +73,7 @@ def _expr_as_dict(expression: Expr, **kwargs: Any) -> dict[str, Any]:
73
73
return fields
74
74
75
75
76
- # TODO: Merge in decorators once Python 3.9 is dropped .
76
+ # YORE: EOL 3.9: Remove block .
77
77
dataclass_opts : dict [str , bool ] = {}
78
78
if sys .version_info >= (3 , 10 ):
79
79
dataclass_opts ["slots" ] = True
@@ -171,6 +171,7 @@ def is_generator(self) -> bool:
171
171
return isinstance (self , ExprSubscript ) and self .canonical_name == "Generator"
172
172
173
173
174
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
174
175
@dataclass (eq = True , ** dataclass_opts )
175
176
class ExprAttribute (Expr ):
176
177
"""Attributes like `a.b`."""
@@ -214,6 +215,7 @@ def canonical_path(self) -> str:
214
215
return self .last .canonical_path
215
216
216
217
218
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
217
219
@dataclass (eq = True , ** dataclass_opts )
218
220
class ExprBinOp (Expr ):
219
221
"""Binary operations like `a + b`."""
@@ -231,6 +233,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
231
233
yield from _yield (self .right , flat = flat )
232
234
233
235
236
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
234
237
@dataclass (eq = True , ** dataclass_opts )
235
238
class ExprBoolOp (Expr ):
236
239
"""Boolean operations like `a or b`."""
@@ -244,6 +247,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
244
247
yield from _join (self .values , f" { self .operator } " , flat = flat )
245
248
246
249
250
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
247
251
@dataclass (eq = True , ** dataclass_opts )
248
252
class ExprCall (Expr ):
249
253
"""Calls like `f()`."""
@@ -265,6 +269,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
265
269
yield ")"
266
270
267
271
272
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
268
273
@dataclass (eq = True , ** dataclass_opts )
269
274
class ExprCompare (Expr ):
270
275
"""Comparisons like `a > b`."""
@@ -282,6 +287,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
282
287
yield from _join (zip_longest (self .operators , [], self .comparators , fillvalue = " " ), " " , flat = flat )
283
288
284
289
290
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
285
291
@dataclass (eq = True , ** dataclass_opts )
286
292
class ExprComprehension (Expr ):
287
293
"""Comprehensions like `a for b in c if d`."""
@@ -307,6 +313,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
307
313
yield from _join (self .conditions , " if " , flat = flat )
308
314
309
315
316
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
310
317
@dataclass (eq = True , ** dataclass_opts )
311
318
class ExprConstant (Expr ):
312
319
"""Constants like `"a"` or `1`."""
@@ -318,6 +325,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: ARG002
318
325
yield self .value
319
326
320
327
328
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
321
329
@dataclass (eq = True , ** dataclass_opts )
322
330
class ExprDict (Expr ):
323
331
"""Dictionaries like `{"a": 0}`."""
@@ -337,6 +345,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
337
345
yield "}"
338
346
339
347
348
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
340
349
@dataclass (eq = True , ** dataclass_opts )
341
350
class ExprDictComp (Expr ):
342
351
"""Dict comprehensions like `{k: v for k, v in a}`."""
@@ -357,6 +366,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
357
366
yield "}"
358
367
359
368
369
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
360
370
@dataclass (eq = True , ** dataclass_opts )
361
371
class ExprExtSlice (Expr ):
362
372
"""Extended slice like `a[x:y, z]`."""
@@ -368,6 +378,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
368
378
yield from _join (self .dims , ", " , flat = flat )
369
379
370
380
381
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
371
382
@dataclass (eq = True , ** dataclass_opts )
372
383
class ExprFormatted (Expr ):
373
384
"""Formatted string like `{1 + 1}`."""
@@ -381,6 +392,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
381
392
yield "}"
382
393
383
394
395
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
384
396
@dataclass (eq = True , ** dataclass_opts )
385
397
class ExprGeneratorExp (Expr ):
386
398
"""Generator expressions like `a for b in c for d in e`."""
@@ -396,6 +408,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
396
408
yield from _join (self .generators , " " , flat = flat )
397
409
398
410
411
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
399
412
@dataclass (eq = True , ** dataclass_opts )
400
413
class ExprIfExp (Expr ):
401
414
"""Conditions like `a if b else c`."""
@@ -415,6 +428,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
415
428
yield from _yield (self .orelse , flat = flat )
416
429
417
430
431
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
418
432
@dataclass (eq = True , ** dataclass_opts )
419
433
class ExprJoinedStr (Expr ):
420
434
"""Joined strings like `f"a {b} c"`."""
@@ -428,6 +442,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
428
442
yield "'"
429
443
430
444
445
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
431
446
@dataclass (eq = True , ** dataclass_opts )
432
447
class ExprKeyword (Expr ):
433
448
"""Keyword arguments like `a=b`."""
@@ -468,6 +483,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
468
483
yield from _yield (self .value , flat = flat )
469
484
470
485
486
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
471
487
@dataclass (eq = True , ** dataclass_opts )
472
488
class ExprVarPositional (Expr ):
473
489
"""Variadic positional parameters like `*args`."""
@@ -480,6 +496,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
480
496
yield from _yield (self .value , flat = flat )
481
497
482
498
499
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
483
500
@dataclass (eq = True , ** dataclass_opts )
484
501
class ExprVarKeyword (Expr ):
485
502
"""Variadic keyword parameters like `**kwargs`."""
@@ -492,6 +509,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
492
509
yield from _yield (self .value , flat = flat )
493
510
494
511
512
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
495
513
@dataclass (eq = True , ** dataclass_opts )
496
514
class ExprLambda (Expr ):
497
515
"""Lambda expressions like `lambda a: a.b`."""
@@ -534,6 +552,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
534
552
yield from _yield (self .body , flat = flat )
535
553
536
554
555
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
537
556
@dataclass (eq = True , ** dataclass_opts )
538
557
class ExprList (Expr ):
539
558
"""Lists like `[0, 1, 2]`."""
@@ -547,6 +566,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
547
566
yield "]"
548
567
549
568
569
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
550
570
@dataclass (eq = True , ** dataclass_opts )
551
571
class ExprListComp (Expr ):
552
572
"""List comprehensions like `[a for b in c]`."""
@@ -564,6 +584,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
564
584
yield "]"
565
585
566
586
587
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
567
588
@dataclass (eq = False , ** dataclass_opts )
568
589
class ExprName (Expr ):
569
590
"""This class represents a Python object identified by a name in a given scope."""
@@ -643,6 +664,7 @@ def is_enum_value(self) -> bool:
643
664
return False
644
665
645
666
667
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
646
668
@dataclass (eq = True , ** dataclass_opts )
647
669
class ExprNamedExpr (Expr ):
648
670
"""Named/assignment expressions like `a := b`."""
@@ -660,6 +682,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
660
682
yield ")"
661
683
662
684
685
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
663
686
@dataclass (eq = True , ** dataclass_opts )
664
687
class ExprParameter (Expr ):
665
688
"""Parameters in function signatures like `a: int = 0`."""
@@ -674,6 +697,7 @@ class ExprParameter(Expr):
674
697
"""Parameter default."""
675
698
676
699
700
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
677
701
@dataclass (eq = True , ** dataclass_opts )
678
702
class ExprSet (Expr ):
679
703
"""Sets like `{0, 1, 2}`."""
@@ -687,6 +711,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
687
711
yield "}"
688
712
689
713
714
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
690
715
@dataclass (eq = True , ** dataclass_opts )
691
716
class ExprSetComp (Expr ):
692
717
"""Set comprehensions like `{a for b in c}`."""
@@ -704,6 +729,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
704
729
yield "}"
705
730
706
731
732
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
707
733
@dataclass (eq = True , ** dataclass_opts )
708
734
class ExprSlice (Expr ):
709
735
"""Slices like `[a:b:c]`."""
@@ -726,6 +752,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
726
752
yield from _yield (self .step , flat = flat )
727
753
728
754
755
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
729
756
@dataclass (eq = True , ** dataclass_opts )
730
757
class ExprSubscript (Expr ):
731
758
"""Subscripts like `a[b]`."""
@@ -756,6 +783,7 @@ def canonical_path(self) -> str:
756
783
return self .left .canonical_path
757
784
758
785
786
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
759
787
@dataclass (eq = True , ** dataclass_opts )
760
788
class ExprTuple (Expr ):
761
789
"""Tuples like `(0, 1, 2)`."""
@@ -773,6 +801,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
773
801
yield ")"
774
802
775
803
804
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
776
805
@dataclass (eq = True , ** dataclass_opts )
777
806
class ExprUnaryOp (Expr ):
778
807
"""Unary operations like `-1`."""
@@ -787,6 +816,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
787
816
yield from _yield (self .value , flat = flat )
788
817
789
818
819
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
790
820
@dataclass (eq = True , ** dataclass_opts )
791
821
class ExprYield (Expr ):
792
822
"""Yield statements like `yield a`."""
@@ -801,6 +831,7 @@ def iterate(self, *, flat: bool = True) -> Iterator[str | Expr]: # noqa: D102
801
831
yield from _yield (self .value , flat = flat )
802
832
803
833
834
+ # YORE: EOL 3.9: Replace `**dataclass_opts` with `slots=True` within line.
804
835
@dataclass (eq = True , ** dataclass_opts )
805
836
class ExprYieldFrom (Expr ):
806
837
"""Yield statements like `yield from a`."""
@@ -1135,7 +1166,7 @@ def _build_yield_from(node: ast.YieldFrom, parent: Module | Class, **kwargs: Any
1135
1166
ast .YieldFrom : _build_yield_from ,
1136
1167
}
1137
1168
1138
- # TODO: remove once Python 3.8 support is dropped
1169
+ # YORE: EOL 3.8: Remove block.
1139
1170
if sys .version_info < (3 , 9 ):
1140
1171
1141
1172
def _build_extslice (node : ast .ExtSlice , parent : Module | Class , ** kwargs : Any ) -> Expr :
0 commit comments