google / google/yapf

Combination of settings causes split_before_first_argument to be ignored

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

Description

I was eager to apply the `split_all_comma_separated_values` option which was added in [this PR](https://github.com/google/yapf/pull/550). However adding this caused a complex piece of code to be end up with bizarre formatting, apparently ignoring some of the other options that I had defined.

### Pipfile

```
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]

[packages]
yapf = "*"

[requires]
python_version = "3.6"
```

This installs yapf 0.22.0 in python 3.6.4 (I know there is a later version of python, I have it locally, pipenv just chooses not to use it for a 3.6 project).

### .style.yapf

```
[style]
align_closing_bracket_with_visual_indent=False
dedent_closing_brackets=True
split_all_comma_separated_values=True
split_before_first_argument=True
```

### Example code

```
def function(argument_one, argument_two, argument_three):
argument_one(
argument_one(argument_two, argument_three),
argument_two,
argument_three,
)
```

### Expected output

This would be in line with what I was expecting. The original code would also be fine as the inner method invocation does not cause the line to exceed the column_limit:

```
def function(argument_one, argument_two, argument_three):
argument_one(
argument_one(
argument_two,
argument_three
),
argument_two,
argument_three,
)
```

(it's worth pointing out that the above code will be reformatted into the imo incorrect code below)

### Actual output

```
def function(argument_one, argument_two, argument_three):
argument_one(
argument_one(argument_two,
argument_three),
argument_two,
argument_three,
)
```

As you can see it appears to be ignoring the following settings:

```
dedent_closing_brackets=True
split_before_first_argument=True
```

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.