Skip to content

Commit dcc92f5

Browse files
authored
Update black tests (#10166)
1 parent a6f32dd commit dcc92f5

File tree

139 files changed

+5480
-1389
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+5480
-1389
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
def foo():
2+
"""
3+
Docstring
4+
"""
5+
6+
# Here we go
7+
if x:
8+
9+
# This is also now fine
10+
a = 123
11+
12+
else:
13+
# But not necessary
14+
a = 123
15+
16+
if y:
17+
18+
while True:
19+
20+
"""
21+
Long comment here
22+
"""
23+
a = 123
24+
25+
if z:
26+
27+
for _ in range(100):
28+
a = 123
29+
else:
30+
31+
try:
32+
33+
# this should be ok
34+
a = 123
35+
except:
36+
37+
"""also this"""
38+
a = 123
39+
40+
41+
def bar():
42+
43+
if x:
44+
a = 123
45+
46+
47+
def baz():
48+
49+
# OK
50+
if x:
51+
a = 123
52+
53+
def quux():
54+
55+
new_line = here
56+
57+
58+
class Cls:
59+
60+
def method(self):
61+
62+
pass
63+
64+
65+
async def async_fn():
66+
67+
"""Docstring."""
68+
69+
70+
@decorated
71+
async def async_fn():
72+
73+
"""Docstring."""
74+
75+
76+
def top_level(
77+
a: int,
78+
b: str,
79+
) -> Whatever[Generic, Something]:
80+
81+
def nested(x: int) -> int:
82+
pass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
def foo():
2+
"""
3+
Docstring
4+
"""
5+
6+
# Here we go
7+
if x:
8+
9+
# This is also now fine
10+
a = 123
11+
12+
else:
13+
# But not necessary
14+
a = 123
15+
16+
if y:
17+
18+
while True:
19+
20+
"""
21+
Long comment here
22+
"""
23+
a = 123
24+
25+
if z:
26+
27+
for _ in range(100):
28+
a = 123
29+
else:
30+
31+
try:
32+
33+
# this should be ok
34+
a = 123
35+
except:
36+
37+
"""also this"""
38+
a = 123
39+
40+
41+
def bar():
42+
43+
if x:
44+
a = 123
45+
46+
47+
def baz():
48+
49+
# OK
50+
if x:
51+
a = 123
52+
53+
54+
def quux():
55+
56+
new_line = here
57+
58+
59+
class Cls:
60+
61+
def method(self):
62+
63+
pass
64+
65+
66+
async def async_fn():
67+
"""Docstring."""
68+
69+
70+
@decorated
71+
async def async_fn():
72+
"""Docstring."""
73+
74+
75+
def top_level(
76+
a: int,
77+
b: str,
78+
) -> Whatever[Generic, Something]:
79+
80+
def nested(x: int) -> int:
81+
pass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
async def func() -> (int):
2+
return 0
3+
4+
5+
@decorated
6+
async def func() -> (int):
7+
return 0
8+
9+
10+
async for (item) in async_iter:
11+
pass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
async def func() -> int:
2+
return 0
3+
4+
5+
@decorated
6+
async def func() -> int:
7+
return 0
8+
9+
10+
async for item in async_iter:
11+
pass

crates/ruff_python_formatter/resources/test/fixtures/black/cases/comments5.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,15 @@ def wat():
4545
@deco2(with_args=True)
4646
# leading 3
4747
@deco3
48-
def decorated1():
49-
...
48+
def decorated1(): ...
5049

5150

5251
# leading 1
5352
@deco1
5453
# leading 2
5554
@deco2(with_args=True)
5655
# leading function comment
57-
def decorated1():
58-
...
56+
def decorated1(): ...
5957

6058

6159
# Note: this is fixed in
@@ -65,8 +63,7 @@ def decorated1():
6563

6664

6765
# This comment should be split from `some_instruction` by two lines but isn't.
68-
def g():
69-
...
66+
def g(): ...
7067

7168

7269
if __name__ == "__main__":

crates/ruff_python_formatter/resources/test/fixtures/black/cases/comments5.py.expect

+3-6
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,15 @@ def wat():
4545
@deco2(with_args=True)
4646
# leading 3
4747
@deco3
48-
def decorated1():
49-
...
48+
def decorated1(): ...
5049

5150

5251
# leading 1
5352
@deco1
5453
# leading 2
5554
@deco2(with_args=True)
5655
# leading function comment
57-
def decorated1():
58-
...
56+
def decorated1(): ...
5957

6058

6159
# Note: this is fixed in
@@ -65,8 +63,7 @@ some_instruction
6563

6664

6765
# This comment should be split from `some_instruction` by two lines but isn't.
68-
def g():
69-
...
66+
def g(): ...
7067

7168

7269
if __name__ == "__main__":
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
if (
2+
True
3+
# sdf
4+
):
5+
print("hw")
6+
7+
if ((
8+
True
9+
# sdf
10+
)):
11+
print("hw")
12+
13+
if ((
14+
# type: ignore
15+
True
16+
)):
17+
print("hw")
18+
19+
if ((
20+
True
21+
# type: ignore
22+
)):
23+
print("hw")
24+
25+
if (
26+
# a long comment about
27+
# the condition below
28+
(a or b)
29+
):
30+
pass
31+
32+
def return_true():
33+
return (
34+
(
35+
True # this comment gets removed accidentally
36+
)
37+
)
38+
39+
def return_true():
40+
return (True) # this comment gets removed accidentally
41+
42+
43+
if (
44+
# huh comment
45+
(True)
46+
):
47+
...
48+
49+
if (
50+
# huh
51+
(
52+
# comment
53+
True
54+
)
55+
):
56+
...
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
if (
2+
True
3+
# sdf
4+
):
5+
print("hw")
6+
7+
if (
8+
True
9+
# sdf
10+
):
11+
print("hw")
12+
13+
if (
14+
# type: ignore
15+
True
16+
):
17+
print("hw")
18+
19+
if (
20+
True
21+
# type: ignore
22+
):
23+
print("hw")
24+
25+
if (
26+
# a long comment about
27+
# the condition below
28+
a
29+
or b
30+
):
31+
pass
32+
33+
34+
def return_true():
35+
return True # this comment gets removed accidentally
36+
37+
38+
def return_true():
39+
return True # this comment gets removed accidentally
40+
41+
42+
if (
43+
# huh comment
44+
True
45+
):
46+
...
47+
48+
if (
49+
# huh
50+
# comment
51+
True
52+
):
53+
...

crates/ruff_python_formatter/resources/test/fixtures/black/cases/conditional_expression.py.expect

+6-4
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ def foo(wait: bool = True):
104104
time.sleep(1) if wait else None
105105

106106

107-
a = "".join((
108-
"", # comment
109-
"" if True else "",
110-
))
107+
a = "".join(
108+
(
109+
"", # comment
110+
"" if True else "",
111+
)
112+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"target_version": "py38"}

0 commit comments

Comments
 (0)