Skip to content

Commit

Permalink
Skip "magic trailing comma" when formatting with black (quantumlib#5170)
Browse files Browse the repository at this point in the history
The "magic trailing comma" is a comma at the end of bracketed list that forces black to format the list entries on separate lines, even if they would fit on one line. For example, if you write:
```python
foo(a, b,)
```
black will see that trailing comma and format this as:
```python
foo(
    a,
    b,
)
```
But with the `skip-magic-trailing-comma` setting enabled this will format on a single line instead
```python
foo(a, b)
```
IME the trailing commas are almost always unintentional, e.g. left over from other refactos, and result in wasted vertical space. I suggest we enable this flag.
  • Loading branch information
maffoo authored and tonybruguier committed Apr 14, 2022
1 parent c923fab commit e3c3a71
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
line-length = 100
target_version = ['py36', 'py37', 'py38']
skip-string-normalization = true
skip-magic-trailing-comma = true

0 comments on commit e3c3a71

Please sign in to comment.