google / yapf

A formatter for Python files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a each_dict_entry_on_separate_line for lists?

marcodicro-dp opened this issue · comments

Is there a way to make each_dict_entry_on_separate_line = true to work for lists? Or any other config for this?

E.g.
image

I'd like to keep my original format of one line per list element (As it would happen if they were dicts, like in the first diff).

Current Style:

[style]
based_on_style = google
indent_width = 2
column_limit = 100
continuation_indent_width = 4
each_dict_entry_on_separate_line = true
allow_split_before_dict_value = false
split_before_logical_operator = true
spaces_before_comment = 1
BLANK_LINE_BEFORE_NESTED_CLASS_OR_DEF = false

Does adding a trailing comma in the list case give the formatting you want?

see this knob:

# Disable the heuristic which places each list element on a separate line
# if the list is comma-terminated.
disable_ending_comma_heuristic = false

Yes! Thank you so much. Didn't know about that