google / google/yapf

Inconsistent line splitting - tuple vs list

Open
#549 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
14k
Forks
904
PR merge metrics
No merged PRs in 30d

Description

I changed my `__slots__` assignments from tuple to list (I got tired of accidentally leaving out the trailing comma in singleton tuples, and to my surprise yapf formatted them differently. Is there a knob for avoiding this? (I would have expected this yapf behavior if I had had a trailing comma ... I tried flipping the setting for `coalesce_brackets`, but that didn't help.

```python
__slots__ = ('for_astn', 'for_exprlist', 'in_testlist', 'comp_iter',
'scope_bindings')
```

vs

```python
__slots__ = [
'for_astn', 'for_exprlist', 'in_testlist', 'comp_iter',
'scope_bindings'
]
```

And here are the diffs from the default style:

```diff
3c3
< align_closing_bracket_with_visual_indent=True
---
> align_closing_bracket_with_visual_indent=False
37c37
< blank_line_before_nested_class_or_def=False
---
> blank_line_before_nested_class_or_def=True
119c119
< indent_dictionary_value=False
---
> indent_dictionary_value=True
160c160
< split_before_closing_bracket=True
---
> split_before_closing_bracket=False
181c181
< split_before_logical_operator=True
---
> split_before_logical_operator=False
200c200
< split_complex_comprehension=False
---
> split_complex_comprehension=True
203c203
< split_penalty_after_opening_bracket=30
---
> split_penalty_after_opening_bracket=-100
224c224
< split_penalty_for_added_line_split=30
---
> split_penalty_for_added_line_split=300
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.