mirror of
https://github.com/astral-sh/ruff.git
synced 2025-12-04 01:36:46 +00:00
Avoiding grouping comprehension targets separately from conditions (#7429)
## Summary Black seems to treat comprehension targets and conditions as if they're in a single group -- so if the comprehension expands, all conditions are rendered on their own line, etc. Closes https://github.com/astral-sh/ruff/issues/7421. ## Test Plan `cargo test` No change in any of the similarity metrics. Before: | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1632 | | django | 0.99982 | 2760 | 37 | | transformers | 0.99957 | 2587 | 399 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99983 | 3496 | 18 | | warehouse | 0.99923 | 648 | 18 | | zulip | 0.99962 | 1437 | 22 | After: | project | similarity index | total files | changed files | |--------------|------------------:|------------------:|------------------:| | cpython | 0.76083 | 1789 | 1632 | | django | 0.99982 | 2760 | 37 | | transformers | 0.99957 | 2587 | 399 | | twine | 1.00000 | 33 | 0 | | typeshed | 0.99983 | 3496 | 18 | | warehouse | 0.99923 | 648 | 18 | | zulip | 0.99962 | 1437 | 22 |
This commit is contained in:
parent
22770fb4be
commit
7e2eba2592
3 changed files with 89 additions and 13 deletions
|
|
@ -79,6 +79,28 @@ a = [
|
|||
aaaaaaaaaaaaaaaaaaaaa = [
|
||||
o for o in self.registry.values if o.__class__ is not ModelAdmin
|
||||
]
|
||||
|
||||
[
|
||||
task
|
||||
for head_name in head_nodes
|
||||
if (task := self.get_task_by_name(head_name))
|
||||
if not None
|
||||
]
|
||||
|
||||
[
|
||||
f(x, y,)
|
||||
for head_name in head_nodes if head_name
|
||||
]
|
||||
|
||||
[
|
||||
f(x, y)
|
||||
for head_name in f(x, y,) if head_name
|
||||
]
|
||||
|
||||
[
|
||||
x
|
||||
for (x, y,) in z if head_name
|
||||
]
|
||||
```
|
||||
|
||||
## Output
|
||||
|
|
@ -178,6 +200,40 @@ a = [
|
|||
aaaaaaaaaaaaaaaaaaaaa = [
|
||||
o for o in self.registry.values if o.__class__ is not ModelAdmin
|
||||
]
|
||||
|
||||
[
|
||||
task
|
||||
for head_name in head_nodes
|
||||
if (task := self.get_task_by_name(head_name))
|
||||
if not None
|
||||
]
|
||||
|
||||
[
|
||||
f(
|
||||
x,
|
||||
y,
|
||||
)
|
||||
for head_name in head_nodes
|
||||
if head_name
|
||||
]
|
||||
|
||||
[
|
||||
f(x, y)
|
||||
for head_name in f(
|
||||
x,
|
||||
y,
|
||||
)
|
||||
if head_name
|
||||
]
|
||||
|
||||
[
|
||||
x
|
||||
for (
|
||||
x,
|
||||
y,
|
||||
) in z
|
||||
if head_name
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue