forked from astral-sh/ruff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Thank you for contributing to Ruff! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? - Does this pull request include references to any relevant issues? --> ## Summary Format `SetComp` like `ListComp`. ## Test Plan Derived from `ListComp`'s fixture.
- Loading branch information
1 parent
8a6afe2
commit 1cc2c87
Showing
6 changed files
with
193 additions
and
35 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/set_comp.py
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,45 @@ | ||
{i for i in []} | ||
|
||
{i for i in [1,]} | ||
|
||
{ | ||
a # a | ||
for # for | ||
c # c | ||
in # in | ||
e # e | ||
} | ||
|
||
{ | ||
# above a | ||
a # a | ||
# above for | ||
for # for | ||
# above c | ||
c # c | ||
# above in | ||
in # in | ||
# above e | ||
e # e | ||
# above if | ||
if # if | ||
# above f | ||
f # f | ||
# above if2 | ||
if # if2 | ||
# above g | ||
g # g | ||
} | ||
|
||
{ | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + [dddddddddddddddddd, eeeeeeeeeeeeeeeeeee] | ||
for | ||
ccccccccccccccccccccccccccccccccccccccc, | ||
ddddddddddddddddddd, [eeeeeeeeeeeeeeeeeeeeee, fffffffffffffffffffffffff] | ||
in | ||
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd | ||
if | ||
fffffffffffffffffffffffffffffffffffffffffff < gggggggggggggggggggggggggggggggggggggggggggggg < hhhhhhhhhhhhhhhhhhhhhhhhhh | ||
if | ||
gggggggggggggggggggggggggggggggggggggggggggg | ||
} |
32 changes: 26 additions & 6 deletions
32
crates/ruff_python_formatter/src/expression/expr_set_comp.rs
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
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
105 changes: 105 additions & 0 deletions
105
crates/ruff_python_formatter/tests/snapshots/format@expression__set_comp.py.snap
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,105 @@ | ||
--- | ||
source: crates/ruff_python_formatter/tests/fixtures.rs | ||
input_file: crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/set_comp.py | ||
--- | ||
## Input | ||
```py | ||
{i for i in []} | ||
{i for i in [1,]} | ||
{ | ||
a # a | ||
for # for | ||
c # c | ||
in # in | ||
e # e | ||
} | ||
{ | ||
# above a | ||
a # a | ||
# above for | ||
for # for | ||
# above c | ||
c # c | ||
# above in | ||
in # in | ||
# above e | ||
e # e | ||
# above if | ||
if # if | ||
# above f | ||
f # f | ||
# above if2 | ||
if # if2 | ||
# above g | ||
g # g | ||
} | ||
{ | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + [dddddddddddddddddd, eeeeeeeeeeeeeeeeeee] | ||
for | ||
ccccccccccccccccccccccccccccccccccccccc, | ||
ddddddddddddddddddd, [eeeeeeeeeeeeeeeeeeeeee, fffffffffffffffffffffffff] | ||
in | ||
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd | ||
if | ||
fffffffffffffffffffffffffffffffffffffffffff < gggggggggggggggggggggggggggggggggggggggggggggg < hhhhhhhhhhhhhhhhhhhhhhhhhh | ||
if | ||
gggggggggggggggggggggggggggggggggggggggggggg | ||
} | ||
``` | ||
|
||
## Output | ||
```py | ||
{i for i in []} | ||
{ | ||
i | ||
for i in [ | ||
1, | ||
] | ||
} | ||
{ | ||
a # a | ||
for c in e # for # c # in # e | ||
} | ||
{ | ||
# above a | ||
a # a | ||
# above for | ||
for # for | ||
# above c | ||
c # c | ||
# above in | ||
in # in | ||
# above e | ||
e # e | ||
# above if | ||
if # if | ||
# above f | ||
f # f | ||
# above if2 | ||
if # if2 | ||
# above g | ||
g # g | ||
} | ||
{ | ||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa | ||
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb | ||
+ [dddddddddddddddddd, eeeeeeeeeeeeeeeeeee] | ||
for ( | ||
ccccccccccccccccccccccccccccccccccccccc, | ||
ddddddddddddddddddd, | ||
[eeeeeeeeeeeeeeeeeeeeee, fffffffffffffffffffffffff], | ||
) in eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeffffffffffffffffffffffffggggggggggggggggggggghhhhhhhhhhhhhhothermoreeand_even_moreddddddddddddddddddddd | ||
if fffffffffffffffffffffffffffffffffffffffffff | ||
< gggggggggggggggggggggggggggggggggggggggggggggg | ||
< hhhhhhhhhhhhhhhhhhhhhhhhhh | ||
if gggggggggggggggggggggggggggggggggggggggggggg | ||
} | ||
``` |