yapf icon indicating copy to clipboard operation
yapf copied to clipboard

yapf not breaking some long, breakable lines

Open TheNeuralBit opened this issue 3 years ago • 0 comments

We use yapf in Apache Beam's Python SDK, and occasionally I run into an issue where yapf will not break a breakable line that's longer than the column limit and I'm not sure why (as an aside, this is particularly frustrating in Beam where we also have pylint enforcing the column limit). Here is an example of a commit I made manually that I would have expected yapf to apply automatically. A sample diff from that commit

class Class(object):
  to_pydatetime = frame_base.wont_implement_method(pd.core.indexes.accessors.DatetimeProperties,
      'to_pydatetime', reason="non-deferred-result")

to:

class Class(object):
  to_pydatetime = frame_base.wont_implement_method(
      pd.core.indexes.accessors.DatetimeProperties, 'to_pydatetime',
      reason="non-deferred-result")

Our config:

[yapf]
indent_width = 2
continuation_indent_width = 4
column_limit = 80
allow_split_before_dict_value = False
blank_line_before_module_docstring = True
coalesce_brackets = True
each_dict_entry_on_separate_line = True
split_all_top_level_comma_separated_values = True
split_arguments_when_comma_terminated = True
split_before_expression_after_opening_paren = True
split_before_first_argument = True
split_before_logical_operator = False
# Use this feature to keep type ignore comments on the correct line
i18n_comment = # type: ignore.*

Is there something we could change in our config to make yapf apply this change? Or is this a bug or WAI?

TheNeuralBit avatar Jun 03 '21 23:06 TheNeuralBit