Comprehensions should not split between tuple-unpacking commas
- Dominant language
- Python
- Stars
- 14k
- Forks
- 904
- PR merge metrics
- No merged PRs in 30d
Description
`split_all_top_level_comma_separated_values` inserts spurious breaks between commas in tuple-unpacking expressions in comprehensions.
Hand-formatted code:
```
results = {
field_name: func(field_value)
for field_name, field_value in self.fields.items()
}
```
YAPF changes this to:
```
results = {
field_name: func(field_value)
for field_name,
field_value in self.fields.items()
}
```
The third line is short enough to fit within the line limit without breaking, and putting a break there decreases readability. I can't see any logical reason there should be a break there.
If I turn off `split_all_top_level_comma_separated_values`, YAPF does not change my hand-formatted code.
Full configuration:
```
[style]
based_on_style = pep8
column_limit = 88
dedent_closing_brackets = False
spaces_before_comment = 2
split_all_top_level_comma_separated_values = True
split_before_arithmetic_operator = True
split_before_logical_operator = True
split_complex_comprehension = True
```
Contributor guide
Assessment
This issue has not been assessed yet.