diff options
author | florentx <florent.xicluna@gmail.com> | 2010-08-29 19:43:28 +0200 |
---|---|---|
committer | florentx <florent.xicluna@gmail.com> | 2010-08-29 19:43:28 +0200 |
commit | 58a7812cb42e825df36fb8a1d5ce7810de2b0bac (patch) | |
tree | 6087b7ababfab6ab96037658a413207d90edb1e3 /pep8.py | |
parent | 91846925bd48cf84b7a1aaa861a685319fe2ffa4 (diff) | |
download | pep8-58a7812cb42e825df36fb8a1d5ce7810de2b0bac.tar.gz |
Fix E301: do not require a blank line before an indented block. (Issue #14)
Diffstat (limited to 'pep8.py')
-rwxr-xr-x | pep8.py | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -116,7 +116,7 @@ INDENT_REGEX = re.compile(r'([ \t]*)') RAISE_COMMA_REGEX = re.compile(r'raise\s+\w+\s*(,)') SELFTEST_REGEX = re.compile(r'(Okay|[EW]\d{3}):\s(.*)') ERRORCODE_REGEX = re.compile(r'[EW]\d{3}') -E301NOT_REGEX = re.compile(r'class |def |u?r?["\']') +DOCSTRING_REGEX = re.compile(r'u?r?["\']') WHITESPACE_AROUND_OPERATOR_REGEX = re.compile(' \W+|\W+ |\t\W+|\W+\t') EXTRANEOUS_WHITESPACE_REGEX = re.compile(r'[[({] | []}),;:]') WHITESPACE_AROUND_NAMED_PARAMETER_REGEX = \ @@ -233,7 +233,8 @@ def maximum_line_length(physical_line): def blank_lines(logical_line, blank_lines, indent_level, line_number, - previous_logical, blank_lines_before_comment): + previous_logical, previous_indent_level, + blank_lines_before_comment): r""" Separate top-level function and class definitions with two blank lines. @@ -266,7 +267,8 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number, logical_line.startswith('class ') or logical_line.startswith('@')): if indent_level: - if not (max_blank_lines or E301NOT_REGEX.match(previous_logical)): + if not (max_blank_lines or previous_indent_level < indent_level or + DOCSTRING_REGEX.match(previous_logical)): return 0, "E301 expected 1 blank line, found 0" elif max_blank_lines != 2: return 0, "E302 expected 2 blank lines, found %d" % max_blank_lines |