google / yapf

A formatter for Python files
Apache License 2.0
13.75k stars 888 forks source link

yapf adds spaces before backslash with every run #1217

Open marcodicro-dp opened 6 months ago

marcodicro-dp commented 6 months ago

Let's say I have this code fragment (note the backslash):

plan_bundles = {
    plan_bundle.bundle_name: {
        'tier_change_options': \
        bundle_util.get_tier_change_options(plan_bundle, details_by_bundle)
    } for plan_bundle in plan.plan_bundles
}

If I run yapf over that file it will add two spaces before the backlash. Result: image

If I run it again: image

So yapf is never happy with my file code style. Is this a bug?

Style config:

[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