Skip to content

Commit

Permalink
Add trailing comma test case for hugging parens (#3991)
Browse files Browse the repository at this point in the history
  • Loading branch information
hauntsaninja committed Oct 27, 2023
1 parent caef196 commit c712d57
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/the_black_code_style/future_style.md
Expand Up @@ -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,
Expand Down
Expand Up @@ -36,6 +36,14 @@ def foo_square_brackets(request):
]
)

func(
[
'a',
'b',
'c',
],
)

func( # a
[ # b
"c", # c
Expand Down Expand Up @@ -171,6 +179,14 @@ def foo_square_brackets(request):
"c",
])

func(
[
"a",
"b",
"c",
],
)

func([ # a # b
"c", # c
"d", # d
Expand Down

0 comments on commit c712d57

Please sign in to comment.