google / google/yapf

yapf adds spaces before backslash with every run

Open
#1,217 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

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

```python3
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](https://github.com/google/yapf/assets/121044623/89e86181-f4dc-408a-9803-e78f59685691)

If I run it again:
![image](https://github.com/google/yapf/assets/121044623/270f5965-2a26-4485-8a45-c040b0d16d74)

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
```

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.