google / google/yapf

Unstable output with broken comment indentation

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

Description

Another situation where YAPF fails to converge on a stable format in one step:

```python
class foo:

#
# A
#
def a():
pass

#
# B
#
def b():
pass
```

is formatted to

```python
class foo:

#
# A
#
def a():
pass

#
# B
#

def b():
pass
```

and then to

```python
class foo:

#
# A
#
def a():
pass

#
# B
#

def b():
pass
```

(note the extra blank line)

I would have thought these sort of unstable outputs would be really easy to check for using fuzzers / property based testing, since the property is so simple: `format(format(a)) == format(a)`. It looks like Python has a property based testing library: https://hypothesis.readthedocs.io/en/latest/

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.