diff options
author | Antony Lee <anntzer.lee@gmail.com> | 2019-03-26 18:01:22 +0100 |
---|---|---|
committer | Antony Lee <anntzer.lee@gmail.com> | 2019-03-26 18:04:38 +0100 |
commit | 7493e0a0e76f02640b6ff0f7cb1619747101a1c6 (patch) | |
tree | 1ca932d1a19351b76f4275f111dcafc1b14fc4f2 /pycodestyle.py | |
parent | 96d2db0fa17cc41ae45bcc6fa5ca72e6f712d1bf (diff) | |
download | pep8-7493e0a0e76f02640b6ff0f7cb1619747101a1c6.tar.gz |
Fix E302 false negative in presence of decorators.
Diffstat (limited to 'pycodestyle.py')
-rwxr-xr-x | pycodestyle.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index 03696b7..ec6b894 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -358,14 +358,15 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number, ): yield 0, "E303 too many blank lines (%d)" % blank_lines elif STARTSWITH_TOP_LEVEL_REGEX.match(logical_line): - # If this is a one-liner (i.e. the next line is not more - # indented), and the previous line is also not deeper - # (it would be better to check if the previous line is part - # of another def/class at the same level), don't require blank - # lines around this. + # If this is a one-liner (i.e. this is not a decorator and the + # next line is not more indented), and the previous line is also + # not deeper (it would be better to check if the previous line + # is part of another def/class at the same level), don't require + # blank lines around this. prev_line = lines[line_number - 2] if line_number >= 2 else '' next_line = lines[line_number] if line_number < len(lines) else '' - if (expand_indent(prev_line) <= indent_level and + if (not logical_line.startswith("@") and + expand_indent(prev_line) <= indent_level and expand_indent(next_line) <= indent_level): return if indent_level: |