Skip to content

Commit 1c8d963

Browse files
authored
Merge pull request #2236 from MrMino/black-magic-comma
Black profile: enable magic comma
2 parents 4ae58fa + ce5b0dc commit 1c8d963

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

docs/configuration/profiles.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ To use any of the listed profiles, use `isort --profile PROFILE_NAME` from the c
1212

1313
- **multi_line_output**: `3`
1414
- **include_trailing_comma**: `True`
15+
- **split_on_trailing_comma**: `True`
1516
- **force_grid_wrap**: `0`
1617
- **use_parentheses**: `True`
1718
- **ensure_newline_before_comments**: `True`

isort/profiles.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
black = {
66
"multi_line_output": 3,
77
"include_trailing_comma": True,
8+
"split_on_trailing_comma": True,
89
"force_grid_wrap": 0,
910
"use_parentheses": True,
1011
"ensure_newline_before_comments": True,

tests/unit/profiles/test_black.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,3 +443,16 @@ def sub(a: np.ndarray, b: np.ndarray) -> np.ndarray: ...
443443
lines_before_imports=2, # will be ignored
444444
lines_after_imports=2, # will be ignored
445445
)
446+
447+
448+
def test_black_trailing_comma():
449+
black_test(
450+
"from x import (a, b, c,)\n",
451+
"""\
452+
from x import (
453+
a,
454+
b,
455+
c,
456+
)
457+
""",
458+
)

0 commit comments

Comments
 (0)