diff options
author | Antony Lee <anntzer.lee@gmail.com> | 2020-02-26 00:44:36 +0100 |
---|---|---|
committer | Antony Lee <anntzer.lee@gmail.com> | 2020-02-26 00:56:41 +0100 |
commit | 9184238b5668829759babcef61a70b2a6d433162 (patch) | |
tree | 7c6dfcc7133e5b533263fe4ab23f38b0db04c92e /pycodestyle.py | |
parent | 68cc24fbe60ce31e2f9b40dc6dd484b2abf3a705 (diff) | |
download | pep8-9184238b5668829759babcef61a70b2a6d433162.tar.gz |
Correctly allow *two* blank lines after a block of one-liners.
Previously
```
def oneliner(): pass
def otheroneliner(): pass
def really_long_func():
with_some_contents
```
would raise an "E302: expected 2 blank lines, found zero" at the last
line of the one liner. Ultimately, this is due to `expand_indent` being
passed a line whose contents are just a newline and nothing else, and
`expand_indent` thinking that the line is indented by 1 character (the
newline), which is wrong.
Fix that by just stripping the newline, and modify a test to cover this
case.
Diffstat (limited to 'pycodestyle.py')
-rwxr-xr-x | pycodestyle.py | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index 705ba25..0d0789d 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -1794,6 +1794,7 @@ def expand_indent(line): >>> expand_indent(' \t') 16 """ + line = line.rstrip('\n\r') if '\t' not in line: return len(line) - len(line.lstrip()) result = 0 |