Adding support for balanced line breaks?
- Dominant language
- Python
- Stars
- 14k
- Forks
- 904
- PR merge metrics
- No merged PRs in 30d
Description
YAPF sometime breaks lines in spots that look a bit odd because they result in a very short and a very long line, whereas breaking the long expression at a different (rather than the first) opportunity would look more natural. Would it be feasible to support this in YAPF or if there already a config that could achieve something similar? Thanks a lot!
## Example 1
Actual:
```python
donated = {
k: v
for k, v in very_long_dict_name.items() if k not in self.copy_keys}
```
Desired:
```python
donated = {
k: v for k, v in very_long_dict_name.items()
if k not in self.copy_keys}
```
## Example 2
Actual:
```python
return str(
src.source_info_util.summarize(src.source_info_util.current(), 30))
```
Desired:
```python
return str(src.source_info_util.summarize(
src.source_info_util.current(), 30))
```
## Configuration
pyproject.toml
```toml
[tool.yapf]
based_on_style = "pep8"
indent_width = 2
allow_multiline_lambdas = true
continuation_align_style = "FIXED"
continuation_indent_width = 4
dedent_closing_brackets = false
each_dict_entry_on_separate_line = false
spaces_around_power_operator = true
split_before_closing_bracket = false
split_before_expression_after_opening_paren = true
split_before_first_argument = true
split_before_logical_operator = false
```
Contributor guide
Assessment
This issue has not been assessed yet.