google / google/yapf

While, and, square brackets, looks messy

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

# Original code

```
page_a_in_a = 0
page_a_in_b = 0
common = 0
history_b = []
while page_a_in_b + common < len(history_b) and page_a_in_a + common < len(history_a) and history_a[page_a_in_a + common] == history_b[page_a_in_b + common]:
common += 1
```

# No config yapf

```
while page_a_in_b + common < len(
history_b
) and page_a_in_a + common < len(history_a) and history_a[
page_a_in_a + common] == history_b[page_a_in_b + common]:
common += 1
```

# Online yapf demo

```
page_a_in_a = 0
page_a_in_b = 0
common = 0
history_b = []
while page_a_in_b + common < len(history_b) and page_a_in_a + common < len(
history_a) and history_a[page_a_in_a + common] == history_b[page_a_in_b
+ common]:
common += 1
```

# Ideal in my opinion

```
while page_a_in_b + common < len(history_b) \
and page_a_in_a + common < len(history_a) \
and history_a[page_a_in_a + common] == history_b[page_a_in_b + common]:
common += 1
```

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.