google / google/yapf

YAPF breaks noqa for multiline strings in brackets

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

Description

It is possible to make a file with a ` # noqa` comment which disables a `flake8` error, which YAPF will move so that the comment is no longer useful.

Install dependencies:

```console
$ pip install yapf flake8

$ pip freeze
flake8==3.5.0
mccabe==0.6.1
pycodestyle==2.3.1
pyflakes==1.6.0
yapf==0.20.1
```

Create `example.py` with the following contents:

```python
foo = (
"""\
Short
Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long
Short
""" # noqa: E501
)
```

There is no `flake8` error because the `E501` error is ignored:

```console
$ flake8 example.py
$
```

Run YAPF, this changes the file:

```console
$ yapf --in-place example.py
$ cat example.py
foo = (
"""\
Short
Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long
Short
"""

# noqa: E501
)
```

`flake8` now does not ignore the error:

```console
$ flake8 example.py
example.py:4:80: E501 line too long (88 > 79 characters)
```

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.