Preserve yield parentheses (#6766)

This commit is contained in:
Micha Reiser 2023-08-22 12:27:20 +02:00 committed by GitHub
parent b52cc84df6
commit ccac9681e1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 121 additions and 16 deletions

View file

@ -71,6 +71,38 @@ def foo():
test, # comment 4
1
)
yield ("Cache key will cause errors if used with memcached: %r " "(longer than %s)" % (
key,
MEMCACHE_MAX_KEY_LENGTH,
)
)
yield "Cache key will cause errors if used with memcached: %r " "(longer than %s)" % (
key,
MEMCACHE_MAX_KEY_LENGTH,
)
yield ("Unnecessary")
yield (
"# * Make sure each ForeignKey and OneToOneField has `on_delete` set "
"to the desired behavior"
)
yield (
"# * Remove `managed = False` lines if you wish to allow "
"Django to create, modify, and delete the table"
)
yield (
"# Feel free to rename the models, but don't rename db_table values or "
"field names."
)
yield "# * Make sure each ForeignKey and OneToOneField has `on_delete` set " "to the desired behavior"
yield "# * Remove `managed = False` lines if you wish to allow " "Django to create, modify, and delete the table"
yield "# Feel free to rename the models, but don't rename db_table values or " "field names."
```
## Output
@ -110,7 +142,7 @@ def foo():
for e in l:
# comment
yield e # Too many parentheses
yield (e) # Too many parentheses
# comment
for ridiculouslylongelementnameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee in l:
@ -135,6 +167,51 @@ def foo():
)
)
)
yield (
"Cache key will cause errors if used with memcached: %r "
"(longer than %s)"
% (
key,
MEMCACHE_MAX_KEY_LENGTH,
)
)
yield "Cache key will cause errors if used with memcached: %r " "(longer than %s)" % (
key,
MEMCACHE_MAX_KEY_LENGTH,
)
yield ("Unnecessary")
yield (
"# * Make sure each ForeignKey and OneToOneField has `on_delete` set "
"to the desired behavior"
)
yield (
"# * Remove `managed = False` lines if you wish to allow "
"Django to create, modify, and delete the table"
)
yield (
"# Feel free to rename the models, but don't rename db_table values or "
"field names."
)
yield (
"# * Make sure each ForeignKey and OneToOneField has `on_delete` set "
"to the desired behavior"
)
yield (
"# * Remove `managed = False` lines if you wish to allow "
"Django to create, modify, and delete the table"
)
yield (
"# Feel free to rename the models, but don't rename db_table values or "
"field names."
)
```