summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lee <IanLee1521@gmail.com>2015-01-11 21:45:23 -0800
committerIan Lee <IanLee1521@gmail.com>2015-01-11 21:45:23 -0800
commitff1d2b70ba418eba6731ad22fd42f161e0f6a8e6 (patch)
tree6378edf9f823107676bbf9300b2f40d032d98f3e
parent510003502b5e067b927e9a62b69937cd9b0eff6e (diff)
parentca85adefd9fe0c679943fd4a78943a64cf7fd380 (diff)
downloadpep8-ff1d2b70ba418eba6731ad22fd42f161e0f6a8e6.tar.gz
Merge pull request #367 from jcrocholl/issue-366
Issue 366
-rw-r--r--CHANGES.txt3
-rwxr-xr-xpep8.py6
-rw-r--r--testsuite/E30.py9
-rw-r--r--testsuite/E30not.py16
4 files changed, 31 insertions, 3 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index 91a2095..0658c41 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -36,6 +36,9 @@ Changes:
* Allow spaces around the equals sign in an annotated function. (Issue #357)
+* Do not check vertical whitespace of non-top level classes / function
+ definitions. (Issue #366)
+
Bug fixes:
* Don't crash if Checker.build_tokens_line() returns None. (Issue #306)
diff --git a/pep8.py b/pep8.py
index 67b32d1..78479bd 100755
--- a/pep8.py
+++ b/pep8.py
@@ -248,7 +248,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number,
E301: class Foo:\n b = 0\n def bar():\n pass
E302: def a():\n pass\n\ndef b(n):\n pass
- E303: def a():\n pass\n\n\n\ndef b(n):\n pass
+ E302: def a():\n pass\n\n\n\ndef b(n):\n pass
E303: def a():\n\n\n\n pass
E304: @decorator\n\ndef a():\n pass
"""
@@ -257,8 +257,6 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number,
if previous_logical.startswith('@'):
if blank_lines:
yield 0, "E304 blank lines found after function decorator"
- elif blank_lines > 2 or (indent_level and blank_lines == 2):
- yield 0, "E303 too many blank lines (%d)" % blank_lines
elif logical_line.startswith(('def ', 'class ', '@')):
if indent_level:
if not (blank_before or previous_indent_level < indent_level or
@@ -266,6 +264,8 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number,
yield 0, "E301 expected 1 blank line, found 0"
elif blank_before != 2:
yield 0, "E302 expected 2 blank lines, found %d" % blank_before
+ elif blank_lines > 2 or (indent_level and blank_lines == 2):
+ yield 0, "E303 too many blank lines (%d)" % blank_lines
def extraneous_whitespace(logical_line):
diff --git a/testsuite/E30.py b/testsuite/E30.py
index d2d7bf3..be41a30 100644
--- a/testsuite/E30.py
+++ b/testsuite/E30.py
@@ -87,4 +87,13 @@ def function():
"""This class docstring comes on line 5.
It gives error E303: too many blank lines (3)
"""
+#: E302
+def a():
+ pass
+
+
+
+
+def b(n):
+ pass
#:
diff --git a/testsuite/E30not.py b/testsuite/E30not.py
index 0fd8fb0..c1df60a 100644
--- a/testsuite/E30not.py
+++ b/testsuite/E30not.py
@@ -6,6 +6,22 @@ class X:
def foo():
pass
#: Okay
+if True:
+ def a():
+ pass
+
+
+ def b():
+ pass
+#: Okay
+if True:
+ class foo():
+ pass
+
+
+ class bar():
+ pass
+#: Okay
# -*- coding: utf-8 -*-
class X:
pass