google / google/yapf

Adjacent string literals of the same type should be on separate lines

Open
#925 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

Suppose I have:

```python
print("Line 1\n"
"Line 2\n"
"Line 3\n")
```

yapf (0.31.0) wants to format it as:

```python
print("Line 1\n" "Line 2\n" "Line 3\n")
```

I argue that this is clearly against the author's intention, and having adjacent string literals of the same type (i.e., both are unadorned double-quoted strings, both are unadorned single-quoted strings, both are raw strings, both are f-strings...) makes no sense since they could have been combined into a single string literal in that case.

If that reasoning isn't compelling enough, then alternatively check if a string literal ends with a `\n`, and never put an adjacent string literal to the right of it.

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.