google / google/yapf

YAPF inserts weird long breaks in function call

Open
#544 11 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
14k
Forks
904
PR merge metrics
No merged PRs in 30d

Description

Using both `yapf 0.21` and the current master (`8d90c204e8abecc59d8e9a6037782293f26fa7f8`), `yapf` formats the following function call:

```python
f(
long_function_name(16, g(lrotate) % 16),
long_function_name(16, g(rrotate) % 16))
```

into the much uglier:

```python
f(
long_function_name(16,
g(lrotate) % 16), long_function_name(
16,
g(rrotate) % 16))
```

If we use a longer function name then `g`, then `yapf` formats

```python
f(
long_function_name(16, func(lrotate) % 16),
long_function_name(16, func(rrotate) % 16))
```

into
```python
f(
long_function_name(16,
func(lrotate) % 16),
long_function_name(16,
func(rrotate) % 16))
```

I'm not sure why the line breaks are necessary (the `long_function_name` calls fit comfortably under the 80 character line limit).

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.