google / google/yapf

Line splits on final paren of empty function call

Open
#567 1 comment 7 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
14k
Forks
904
PR merge metrics
No merged PRs in 30d

Description

Here are a couple of examples that do a very strange split on method calls without arguments using the default settings in yapf. I can't imagine anyone would want this as the default behavior since it seems to employ a very strict line length requirement.

```
$ yapf -d example.py
--- example.py (original)
+++ example.py (reformatted)
@@ -1,3 +1,5 @@
-line_that_is_81_characters_wide = some_functions_perhaps() or not other_methods()
+line_that_is_82_characters_wide = some_functions_perhaps(
+) or not other_methods()

-line_that_is_81_characters_wide = some_boolean_operator or not and_other_methods()
+line_that_is_82_characters_wide = some_boolean_operator or not and_other_methods(
+)
```

There are probably better solutions to this, one would be to simply relax the line length rules to be a bit more forgiving. The other would be to wrap after the closing paren when possible or wrap the entire method. Or pretty much anything except for what its doing. eg:

```
$ yapf -d example.py
--- example.py (original)
+++ example.py (reformatted)
@@ -1,3 +1,5 @@
-line_that_is_81_characters_wide = some_functions_perhaps() or not other_methods()
+line_that_is_82_characters_wide = some_functions_perhaps() or \
+ not other_methods()

-line_that_is_81_characters_wide = some_boolean_operator or not and_other_methods()
+line_that_is_82_characters_wide = some_boolean_operator or not \
+ and_other_methods()
```

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.