-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add trailing commas to support
collections.py
test (#7)
- Loading branch information
1 parent
41c10f8
commit 8081cf5
Showing
6 changed files
with
323 additions
and
123 deletions.
There are no files selected for viewing
174 changes: 174 additions & 0 deletions
174
crates/ruff_fmt/resources/test/fixtures/black/simple_cases/collections.bak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
import core, time, a | ||
|
||
from . import A, B, C | ||
|
||
# keeps existing trailing comma | ||
from foo import ( | ||
bar, | ||
) | ||
|
||
# also keeps existing structure | ||
from foo import ( | ||
baz, | ||
qux, | ||
) | ||
|
||
# `as` works as well | ||
from foo import ( | ||
xyzzy as magic, | ||
) | ||
|
||
a = {1,2,3,} | ||
b = { | ||
1,2, | ||
3} | ||
c = { | ||
1, | ||
2, | ||
3, | ||
} | ||
x = 1, | ||
y = narf(), | ||
nested = {(1,2,3),(4,5,6),} | ||
nested_no_trailing_comma = {(1,2,3),(4,5,6)} | ||
nested_long_lines = ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "cccccccccccccccccccccccccccccccccccccccc", (1, 2, 3), "dddddddddddddddddddddddddddddddddddddddd"] | ||
{"oneple": (1,),} | ||
{"oneple": (1,)} | ||
['ls', 'lsoneple/%s' % (foo,)] | ||
x = {"oneple": (1,)} | ||
y = {"oneple": (1,),} | ||
assert False, ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa wraps %s" % bar) | ||
|
||
# looping over a 1-tuple should also not get wrapped | ||
for x in (1,): | ||
pass | ||
for (x,) in (1,), (2,), (3,): | ||
pass | ||
|
||
[1, 2, 3,] | ||
|
||
division_result_tuple = (6/2,) | ||
print("foo %r", (foo.bar,)) | ||
|
||
if True: | ||
IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING = ( | ||
Config.IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING | ||
| {pylons.controllers.WSGIController} | ||
) | ||
|
||
if True: | ||
ec2client.get_waiter('instance_stopped').wait( | ||
InstanceIds=[instance.id], | ||
WaiterConfig={ | ||
'Delay': 5, | ||
}) | ||
ec2client.get_waiter("instance_stopped").wait( | ||
InstanceIds=[instance.id], | ||
WaiterConfig={"Delay": 5,}, | ||
) | ||
ec2client.get_waiter("instance_stopped").wait( | ||
InstanceIds=[instance.id], WaiterConfig={"Delay": 5,}, | ||
) | ||
|
||
# output | ||
|
||
|
||
import core, time, a | ||
|
||
from . import A, B, C | ||
|
||
# keeps existing trailing comma | ||
from foo import ( | ||
bar, | ||
) | ||
|
||
# also keeps existing structure | ||
from foo import ( | ||
baz, | ||
qux, | ||
) | ||
|
||
# `as` works as well | ||
from foo import ( | ||
xyzzy as magic, | ||
) | ||
|
||
a = { | ||
1, | ||
2, | ||
3, | ||
} | ||
b = {1, 2, 3} | ||
c = { | ||
1, | ||
2, | ||
3, | ||
} | ||
x = (1,) | ||
y = (narf(),) | ||
nested = { | ||
(1, 2, 3), | ||
(4, 5, 6), | ||
} | ||
nested_no_trailing_comma = {(1, 2, 3), (4, 5, 6)} | ||
nested_long_lines = [ | ||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | ||
"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", | ||
"cccccccccccccccccccccccccccccccccccccccc", | ||
(1, 2, 3), | ||
"dddddddddddddddddddddddddddddddddddddddd", | ||
] | ||
{ | ||
"oneple": (1,), | ||
} | ||
{"oneple": (1,)} | ||
["ls", "lsoneple/%s" % (foo,)] | ||
x = {"oneple": (1,)} | ||
y = { | ||
"oneple": (1,), | ||
} | ||
assert False, ( | ||
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa wraps %s" | ||
% bar | ||
) | ||
|
||
# looping over a 1-tuple should also not get wrapped | ||
for x in (1,): | ||
pass | ||
for (x,) in (1,), (2,), (3,): | ||
pass | ||
|
||
[ | ||
1, | ||
2, | ||
3, | ||
] | ||
|
||
division_result_tuple = (6 / 2,) | ||
print("foo %r", (foo.bar,)) | ||
|
||
if True: | ||
IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING = ( | ||
Config.IGNORED_TYPES_FOR_ATTRIBUTE_CHECKING | ||
| {pylons.controllers.WSGIController} | ||
) | ||
|
||
if True: | ||
ec2client.get_waiter("instance_stopped").wait( | ||
InstanceIds=[instance.id], | ||
WaiterConfig={ | ||
"Delay": 5, | ||
}, | ||
) | ||
ec2client.get_waiter("instance_stopped").wait( | ||
InstanceIds=[instance.id], | ||
WaiterConfig={ | ||
"Delay": 5, | ||
}, | ||
) | ||
ec2client.get_waiter("instance_stopped").wait( | ||
InstanceIds=[instance.id], | ||
WaiterConfig={ | ||
"Delay": 5, | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.