google / google/yapf

yapf formatting differs based on Python 3 version

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

Description

I have the following code:

```python3
class A:
def __init__(self, *extras):
super().__init__(
*chain((AbcdEfghij, AbcDef, AbcdEfghiJklmnopqr), extras))
```

Running yapf master e43ad9d/0.26.0/0.25.0 on Python 3.7.2 gives the following output:

```console
$ yapf --style=pep8 -d testfile.py
--- testfile.py (original)
+++ testfile.py (reformatted)
@@ -1,4 +1,4 @@
class A:
def __init__(self, *extras):
- super().__init__(
- *chain((AbcdEfghij, AbcDef, AbcdEfghiJklmnopqr), extras))
+ super().__init__(*chain((AbcdEfghij, AbcDef,
+ AbcdEfghiJklmnopqr), extras))
```

Running yapf master e43ad9d/0.26.0/0.25.0 on Python 3.5.2 (Ubuntu 16.04 default) gives the following output:

```console
$ yapf --style=pep8 -d testfile.py
$ echo $?
0
```

We expect users to run yapf locally and we run it in CI. Having different formatting requirements between a local runs and CI is very unfortunate for us.

Notes:
* I know that yapf 0.26.0 doesn't support Python 3.5 any more. Still the same bug is present in the previous version 0.25.0 which did support Python 3.5. (We still need to use it for Ubuntu 16.04 users.)
* The same bug can be observed when using the `google` instead of the `pep8` style.
* I didn't bisect which Python version is the tipping point for this behavior, and I didn't exclude other factors beyond the Python version which might also play a role.

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.