Add trailing comma test case for hugging parens (#3991)

This commit is contained in:
Shantanu 2023-10-27 12:17:54 -07:00 committed by GitHub
parent caef19689b
commit c712d57ca9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -139,6 +139,19 @@ foo([
])
```
You can use a magic trailing comma to avoid this compacting behavior; by default,
_Black_ will not reformat the following code:
```python
foo(
[
1,
2,
3,
],
)
```
### Improved multiline string handling
_Black_ is smarter when formatting multiline strings, especially in function arguments,

View File

@ -36,6 +36,14 @@ def foo_square_brackets(request):
]
)
func(
[
'a',
'b',
'c',
],
)
func( # a
[ # b
"c", # c
@ -171,6 +179,14 @@ def foo_square_brackets(request):
"c",
])
func(
[
"a",
"b",
"c",
],
)
func([ # a # b
"c", # c
"d", # d