Skip to content

Commit 67b0434

Browse files
authored
Use pass over ellipsis in non-function/class contexts (#8049)
Split out of #8044: In preview style, ellipsis are also collapsed in non-stub files. This should only affect function/class contexts since for other statements stub are generally not used. I've updated our tests to use `pass` instead to reflect this, which makes tracking the preview style changes much easier.
1 parent 693f957 commit 67b0434

24 files changed

+294
-294
lines changed

crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/binary.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
dddddddddddddddddddd,
7676
eeeeeeeeee,
7777
] & aaaaaaaaaaaaaaaaaaaaaaaaaa:
78-
...
78+
pass
7979

8080
if [
8181
aaaaaaaaaaaaa,
@@ -84,7 +84,7 @@
8484
dddddddddddddddddddd,
8585
eeeeeeeeee,
8686
] & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
87-
...
87+
pass
8888

8989
# Right only can break
9090
if aaaaaaaaaaaaaaaaaaaaaaaaaa & [
@@ -94,7 +94,7 @@
9494
dddddddddddddddddddd,
9595
eeeeeeeeee,
9696
]:
97-
...
97+
pass
9898

9999
if aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa & [
100100
aaaaaaaaaaaaa,
@@ -103,7 +103,7 @@
103103
dddddddddddddddddddd,
104104
eeeeeeeeee,
105105
]:
106-
...
106+
pass
107107

108108

109109
# Left or right can break
@@ -114,7 +114,7 @@
114114
dddddddddddddddddddd,
115115
eeeeeeeeee,
116116
]:
117-
...
117+
pass
118118

119119
if [
120120
aaaaaaaaaaaaa,
@@ -123,7 +123,7 @@
123123
dddddddddddddddddddd,
124124
eeeeeeeeee,
125125
] & [2222, 333]:
126-
...
126+
pass
127127

128128
if [
129129
aaaaaaaaaaaaa,
@@ -132,7 +132,7 @@
132132
dddddddddddddddddddd,
133133
eeeeeeeeee,
134134
] & [fffffffffffffffff, gggggggggggggggggggg, hhhhhhhhhhhhhhhhhhhhh, iiiiiiiiiiiiiiii, jjjjjjjjjjjjj]:
135-
...
135+
pass
136136

137137
if (
138138
# comment
@@ -152,7 +152,7 @@
152152
]:
153153
pass
154154

155-
...
155+
pass
156156

157157
# Nesting
158158
if (aaaa + b) & [
@@ -162,7 +162,7 @@
162162
iiiiiiiiiiiiiiii,
163163
jjjjjjjjjjjjj,
164164
]:
165-
...
165+
pass
166166

167167
if [
168168
fffffffffffffffff,
@@ -171,7 +171,7 @@
171171
iiiiiiiiiiiiiiii,
172172
jjjjjjjjjjjjj,
173173
] & (a + b):
174-
...
174+
pass
175175

176176

177177
if [
@@ -185,7 +185,7 @@
185185
a
186186
+ b
187187
):
188-
...
188+
pass
189189

190190
if (
191191
[
@@ -199,7 +199,7 @@
199199
# comment
200200
a + b
201201
):
202-
...
202+
pass
203203

204204

205205
# Unstable formatting in https://github.com/realtyem/synapse-unraid/blob/unraid_develop/synapse/handlers/presence.py

crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/boolean_operation.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
and self._returncode
1717
and self._proc.poll()
1818
):
19-
...
19+
pass
2020

2121
if (
2222
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
@@ -26,14 +26,14 @@
2626
and aaaaaaaaaaaaaaaaaaaaaaaaaa
2727
and aaaaaaaaaaaaaaaaaaaaaaaaaaaa
2828
):
29-
...
29+
pass
3030

3131

3232
if (
3333
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaas
3434
and aaaaaaaaaaaaaaaaa
3535
):
36-
...
36+
pass
3737

3838

3939
if [2222, 333] and [
@@ -43,7 +43,7 @@
4343
dddddddddddddddddddd,
4444
eeeeeeeeee,
4545
]:
46-
...
46+
pass
4747

4848
if [
4949
aaaaaaaaaaaaa,

crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/slice.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
# Spacing around the colon(s)
6767
def a():
68-
...
68+
pass
6969

7070
e00 = "e"[:]
7171
e01 = "e"[:1]

crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/unary.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,18 @@
139139

140140
# Regression: https://github.com/astral-sh/ruff/issues/5338
141141
if a and not aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
142-
...
142+
pass
143143

144144
if (
145145
not
146146
# comment
147147
a):
148-
...
148+
pass
149149

150150
if (
151151
not # comment
152152
a):
153-
...
153+
pass
154154

155155
# Regression test for: https://github.com/astral-sh/ruff/issues/7423
156156
if True:

crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/unsplittable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
for converter in connection.ops.get_db_converters(
5252
expression
5353
) + expression.get_db_converters(connection):
54-
...
54+
pass
5555

5656

5757
aaa = (

crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/for.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@
1515
pass
1616

1717
else:
18-
...
18+
pass
1919

2020
for (
2121
x,
2222
y,
2323
) in z: # comment
24-
...
24+
pass
2525

2626

2727
# remove brackets around x,y but keep them around z,w
2828
for (x, y) in (z, w):
29-
...
29+
pass
3030

3131

3232
# type comment
3333
for x in (): # type: int
34-
...
34+
pass
3535

3636
# Tuple parentheses for iterable.
3737
for x in 1, 2, 3:

crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/if.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919

2020
if x == y:
2121
if y == z:
22-
...
22+
pass
2323

2424
if a == b:
25-
...
25+
pass
2626
else: # trailing comment
27-
...
27+
pass
2828

2929
# trailing else comment
3030

@@ -34,11 +34,11 @@
3434
2222222222222222222222,
3535
3333333333
3636
]:
37-
...
37+
pass
3838

3939

4040
else:
41-
...
41+
pass
4242

4343
# Regression test: Don't drop the trailing comment by associating it with the elif
4444
# instead of the else.

crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/match.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ def foo():
206206
case (
207207
True # trailing
208208
):
209-
...
209+
pass
210210
case False:
211-
...
211+
pass
212212

213213

214214
match foo:
@@ -406,39 +406,39 @@ def foo():
406406
case Point2D(
407407
# own line
408408
):
409-
...
409+
pass
410410

411411
case (
412412
Point2D
413413
# own line
414414
()
415415
):
416-
...
416+
pass
417417

418418
case Point2D( # end of line line
419419
):
420-
...
420+
pass
421421

422422
case Point2D( # end of line
423423
0, 0
424424
):
425-
...
425+
pass
426426

427427
case Point2D(0, 0):
428-
...
428+
pass
429429

430430
case Point2D(
431431
( # end of line
432432
# own line
433433
0
434434
), 0):
435-
...
435+
pass
436436

437437
case Point3D(x=0, y=0, z=000000000000000000000000000000000000000000000000000000000000000000000000000000000):
438-
...
438+
pass
439439

440440
case Bar(0, a=None, b="hello"):
441-
...
441+
pass
442442

443443
case FooBar(# leading
444444
# leading
@@ -449,7 +449,7 @@ def foo():
449449
# trailing
450450
# trailing
451451
):
452-
...
452+
pass
453453

454454
case A(
455455
b # b
@@ -481,26 +481,26 @@ def foo():
481481
# own line 4
482482
c # trailing 5
483483
):
484-
...
484+
pass
485485

486486
case (
487487
(a)
488488
| # trailing
489489
( b )
490490
):
491-
...
491+
pass
492492

493493
case (a|b|c):
494-
...
494+
pass
495495

496496
case foo | bar | aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh:
497-
...
497+
pass
498498

499499
case ( # end of line
500500
a | b
501501
# own line
502502
):
503-
...
503+
pass
504504

505505

506506
# Single-element tuples.

0 commit comments

Comments
 (0)