google / google/yapf

Add option to improve readability of multi-function calls

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

Description

As an example, whenever we write the following code:

```python
list(map(str, [
a,
b,
c,
d,
e,
f,
g,
h,
i,
j,
a,
b,
c,
d,
e,
f,
g,
h,
i,
j,
]))

```

YAPF converts it to:

```python
list(
map(
str, [
a,
b,
c,
d,
e,
f,
g,
h,
i,
j,
a,
b,
c,
d,
e,
f,
g,
h,
i,
j,
]
)
)

```

This is not ideal because it feels even harder to read when we split out `list`, `map`, and `str` to separate lines. I haven't seen any other issues talking about this weird behavior, but I think it's worth considering. Hopefully I haven't created a duplicate. Thank you for reading this!

In case it helps, here is my YAPF configuration:

```ini
[style]
based_on_style = pep8
allow_multiline_lambdas = False
allow_multiline_dictionary_keys = False
blank_line_before_nested_class_or_def = False
column_limit = 79
coalesce_brackets = True
continuation_indent_width = 4
dedent_closing_brackets = True
each_dict_entry_on_separate_line = False
indent_dictionary_value = True
join_multiple_lines = False
indent_width = 4
spaces_around_power_operator = True
spaces_around_default_or_named_assign = False
spaces_before_comment = 2
space_between_ending_comma_and_closing_bracket = False
split_arguments_when_comma_terminated = False
split_before_bitwise_operator = True
split_before_dict_set_generator = True
split_before_first_argument = True
split_before_logical_operator = True
split_before_named_assigns = True
use_tabs = False
```

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.