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
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pep8.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
Expand All @@ -257,15 +257,15 @@ 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
DOCSTRING_REGEX.match(previous_logical)):
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):
Expand Down
9 changes: 9 additions & 0 deletions testsuite/E30.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#:
16 changes: 16 additions & 0 deletions testsuite/E30not.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down