mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-31 07:38:00 +00:00
Preserve generator parentheses in single argument call expressions (#7226)
This commit is contained in:
parent
e376c3ff7e
commit
a352f2f092
5 changed files with 67 additions and 14 deletions
|
@ -386,10 +386,10 @@ threshold_date = datetime.datetime.now() - datetime.timedelta( # comment
|
|||
)
|
||||
|
||||
# Parenthesized and opening-parenthesis comments
|
||||
func(x for x in y)
|
||||
func((x for x in y))
|
||||
|
||||
func( # outer comment
|
||||
x for x in y
|
||||
(x for x in y)
|
||||
)
|
||||
|
||||
func(
|
||||
|
@ -399,9 +399,11 @@ func(
|
|||
)
|
||||
|
||||
func(
|
||||
# inner comment
|
||||
x
|
||||
for x in y
|
||||
(
|
||||
# inner comment
|
||||
x
|
||||
for x in y
|
||||
)
|
||||
)
|
||||
|
||||
func( # outer comment
|
||||
|
|
|
@ -22,6 +22,11 @@ f((1) for _ in (a))
|
|||
# combination of the two above
|
||||
f(((1) for _ in (a)))
|
||||
|
||||
bases = tuple(
|
||||
(base._meta.label_lower if hasattr(base, "_meta") else base)
|
||||
for base in flattened_bases
|
||||
)
|
||||
|
||||
|
||||
# black keeps these atm, but intends to remove them in the future:
|
||||
# https://github.com/psf/black/issues/2943
|
||||
|
@ -67,13 +72,18 @@ sum((a for b in c), start=0)
|
|||
|
||||
# black keeps these atm, but intends to remove them in the future:
|
||||
# https://github.com/psf/black/issues/2943
|
||||
f(1 for _ in a)
|
||||
f((1 for _ in a))
|
||||
|
||||
# make sure source parenthesis detection isn't fooled by these
|
||||
f((1) for _ in (a))
|
||||
|
||||
# combination of the two above
|
||||
f((1) for _ in (a))
|
||||
f(((1) for _ in (a)))
|
||||
|
||||
bases = tuple(
|
||||
(base._meta.label_lower if hasattr(base, "_meta") else base)
|
||||
for base in flattened_bases
|
||||
)
|
||||
|
||||
|
||||
# black keeps these atm, but intends to remove them in the future:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue