mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:34:40 +00:00
Use space
separator before parenthesiszed expressions in comprehensions with leading comments. (#12282)
This commit is contained in:
parent
d0298dc26d
commit
bd01004a42
4 changed files with 274 additions and 6 deletions
|
@ -111,6 +111,69 @@ aaaaaaaaaaaaaaaaaaaaa = [
|
|||
# Parenthesized targets and iterators.
|
||||
[x for (x) in y]
|
||||
[x for x in (y)]
|
||||
|
||||
|
||||
# Leading expression comments:
|
||||
y = [
|
||||
a
|
||||
for (
|
||||
# comment
|
||||
a
|
||||
) in (
|
||||
# comment
|
||||
x
|
||||
)
|
||||
if (
|
||||
# asdasd
|
||||
"askldaklsdnmklasmdlkasmdlkasmdlkasmdasd"
|
||||
!= "as,mdnaskldmlkasdmlaksdmlkasdlkasdm"
|
||||
and "zxcm,.nzxclm,zxnckmnzxckmnzxczxc" != "zxcasdasdlmnasdlknaslkdnmlaskdm"
|
||||
)
|
||||
if (
|
||||
# comment
|
||||
x
|
||||
)
|
||||
]
|
||||
|
||||
# Tuple target:
|
||||
y = [
|
||||
a
|
||||
for
|
||||
# comment
|
||||
a, b
|
||||
in x
|
||||
if True
|
||||
]
|
||||
|
||||
|
||||
y = [
|
||||
a
|
||||
for (
|
||||
# comment
|
||||
a, b
|
||||
)
|
||||
in x
|
||||
if True
|
||||
]
|
||||
|
||||
|
||||
y = [
|
||||
a
|
||||
for
|
||||
# comment
|
||||
a
|
||||
in
|
||||
# comment
|
||||
x
|
||||
if
|
||||
# asdasd
|
||||
"askldaklsdnmklasmdlkasmdlkasmdlkasmdasd"
|
||||
!= "as,mdnaskldmlkasdmlaksdmlkasdlkasdm"
|
||||
and "zxcm,.nzxclm,zxnckmnzxckmnzxczxc" != "zxcasdasdlmnasdlknaslkdnmlaskdm"
|
||||
if
|
||||
# comment
|
||||
x
|
||||
]
|
||||
```
|
||||
|
||||
## Output
|
||||
|
@ -254,7 +317,104 @@ aaaaaaaaaaaaaaaaaaaaa = [
|
|||
# Parenthesized targets and iterators.
|
||||
[x for (x) in y]
|
||||
[x for x in (y)]
|
||||
|
||||
|
||||
# Leading expression comments:
|
||||
y = [
|
||||
a
|
||||
for
|
||||
(
|
||||
# comment
|
||||
a
|
||||
) in
|
||||
(
|
||||
# comment
|
||||
x
|
||||
)
|
||||
if
|
||||
(
|
||||
# asdasd
|
||||
"askldaklsdnmklasmdlkasmdlkasmdlkasmdasd"
|
||||
!= "as,mdnaskldmlkasdmlaksdmlkasdlkasdm"
|
||||
and "zxcm,.nzxclm,zxnckmnzxckmnzxczxc" != "zxcasdasdlmnasdlknaslkdnmlaskdm"
|
||||
)
|
||||
if
|
||||
(
|
||||
# comment
|
||||
x
|
||||
)
|
||||
]
|
||||
|
||||
# Tuple target:
|
||||
y = [
|
||||
a
|
||||
for
|
||||
# comment
|
||||
a, b in x
|
||||
if True
|
||||
]
|
||||
|
||||
|
||||
y = [
|
||||
a
|
||||
for (
|
||||
# comment
|
||||
a,
|
||||
b,
|
||||
) in x
|
||||
if True
|
||||
]
|
||||
|
||||
|
||||
y = [
|
||||
a
|
||||
for
|
||||
# comment
|
||||
a in
|
||||
# comment
|
||||
x
|
||||
if
|
||||
# asdasd
|
||||
"askldaklsdnmklasmdlkasmdlkasmdlkasmdasd" != "as,mdnaskldmlkasdmlaksdmlkasdlkasdm"
|
||||
and "zxcm,.nzxclm,zxnckmnzxckmnzxczxc" != "zxcasdasdlmnasdlknaslkdnmlaskdm"
|
||||
if
|
||||
# comment
|
||||
x
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Preview changes
|
||||
```diff
|
||||
--- Stable
|
||||
+++ Preview
|
||||
@@ -142,24 +142,20 @@
|
||||
# Leading expression comments:
|
||||
y = [
|
||||
a
|
||||
- for
|
||||
- (
|
||||
+ for (
|
||||
# comment
|
||||
a
|
||||
- ) in
|
||||
- (
|
||||
+ ) in (
|
||||
# comment
|
||||
x
|
||||
)
|
||||
- if
|
||||
- (
|
||||
+ if (
|
||||
# asdasd
|
||||
"askldaklsdnmklasmdlkasmdlkasmdlkasmdasd"
|
||||
!= "as,mdnaskldmlkasdmlaksdmlkasdlkasdm"
|
||||
and "zxcm,.nzxclm,zxnckmnzxckmnzxczxc" != "zxcasdasdlmnasdlknaslkdnmlaskdm"
|
||||
)
|
||||
- if
|
||||
- (
|
||||
+ if (
|
||||
# comment
|
||||
x
|
||||
)
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue