Preserve generator parentheses in single argument call expressions (#7226)

This commit is contained in:
Micha Reiser 2023-09-08 10:53:34 +02:00 committed by GitHub
parent e376c3ff7e
commit a352f2f092
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 67 additions and 14 deletions

View file

@ -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

View file

@ -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: