Skip to content
This repository was archived by the owner on May 24, 2021. It is now read-only.

Commit 4c04de2

Browse files
YapfBear: Add coalesce_brackets
1 parent 8892767 commit 4c04de2

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

bears/python/YapfBear.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class YapfBear(LocalBear):
2424
LICENSE = 'AGPL-3.0'
2525
CAN_FIX = {'Formatting'}
2626

27-
# TODO Add coalesce_brackets once supported by yapf
2827
@deprecate_settings(indent_size='tab_width')
2928
def run(self, filename, file,
3029
max_line_length: int=79,
@@ -34,6 +33,7 @@ def run(self, filename, file,
3433
continuation_tab_width: int=SpacingHelper.DEFAULT_TAB_WIDTH,
3534
dedent_closing_brackets: bool=False,
3635
indent_dictionary_value: bool=False,
36+
coalesce_brackets: bool=False,
3737
join_multiple_lines: bool=True,
3838
spaces_around_power_operator: bool=True,
3939
spaces_before_comment: int=2,
@@ -64,6 +64,27 @@ def run(self, filename, file,
6464
:param indent_dictionary_value:
6565
Indents the dictionary value if it cannot fit on the same line as
6666
the dictionary key.
67+
:param coalesce_brackets:
68+
Prevents splitting consecutive brackets. Only relevant when
69+
``dedent_closing_brackets`` is set.
70+
Example:
71+
If ``True``,
72+
73+
```
74+
call_func_that_takes_a_dict(
75+
{
76+
'key1': 'value1',
77+
'key2': 'value2',
78+
}
79+
)
80+
```
81+
would reformat to:
82+
```
83+
call_func_that_takes_a_dict({
84+
'key1': 'value1',
85+
'key2': 'value2',
86+
})
87+
```
6788
:param join_multiple_lines:
6889
Joins short lines into one line.
6990
:param spaces_around_power_operator:
@@ -104,6 +125,7 @@ def run(self, filename, file,
104125
join_multiple_lines = {join_multiple_lines}
105126
spaces_around_power_operator = {spaces_around_power_operator}
106127
spaces_before_comment = {spaces_before_comment}
128+
coalesce_brackets = {coalesce_brackets}
107129
split_before_bitwise_operator = {split_before_bitwise_operator}
108130
split_before_first_argument = {split_before_first_argument}
109131
split_before_logical_operator = {split_before_logical_operator}

0 commit comments

Comments
 (0)