google / google/yapf

Strange formatting difference when running python 3.6 versus 3.7

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

Description

Here's some code:

```python
class Blah:
async def __anext__(self):
return { await self._signal_queue.__anext__()}
```

Notice the weird space before the `await`.

According to yapf 0.24.0 (and earlier), when running on python 3.6, this code is formatted correctly:

```
/tmp$ p36/bin/yapf --version
yapf 0.24.0
/tmp$ p36/bin/python --version
Python 3.6.5
/tmp$ p36/bin/yapf -d asdf.py
```

According to yapf 0.24.0 (and earlier), when running on python 3.7, this code is formatted **in**correctly:

```
/tmp$ p37/bin/yapf --version
yapf 0.24.0
/tmp$ p37/bin/python --version
Python 3.7.0b3
/tmp$ p37/bin/yapf -d asdf.py
--- asdf.py (original)
+++ asdf.py (reformatted)
@@ -1,3 +1,3 @@
class Blah:
async def __anext__(self):
- return { await self._signal_queue.__anext__()}
+ return {await self._signal_queue.__anext__()}
```

This leads to frustration when some members of a team are using python 3.6, and some are using 3.7.

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.