summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpycodestyle.py13
-rw-r--r--testsuite/E30.py8
2 files changed, 15 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:
diff --git a/testsuite/E30.py b/testsuite/E30.py
index 320b2a1..15fbdf3 100644
--- a/testsuite/E30.py
+++ b/testsuite/E30.py
@@ -181,3 +181,11 @@ def foo():
def bar(): pass
def baz():
pass
+#: E302:5:1
+def f():
+ pass
+
+# wat
+@hi
+def g():
+ pass