Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions testsuite/E30.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,11 @@ def foo():
def bar(): pass
def baz():
pass
#: E302:5:1
def f():
pass

# wat
@hi
def g():
pass