Skip to content

Commit 98dee57

Browse files
committed
Improve error message and add some comments
1 parent 36e3400 commit 98dee57

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pycodestyle.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,16 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number,
273273
DOCSTRING_REGEX.match(previous_logical)):
274274
ancestor_level = indent_level
275275
nested = False
276+
# Search backwards for a def ancestor or tree root (top level).
276277
for line in lines[line_number - 2::-1]:
277278
if line.strip() and expand_indent(line) < ancestor_level:
278279
ancestor_level = expand_indent(line)
279280
nested = line.lstrip().startswith('def ')
280281
if nested or ancestor_level == 0:
281282
break
282283
if nested:
283-
yield 0, "E306 expected 1 blank line, found 0" \
284-
" (nested definition)"
284+
yield 0, "E306 expected 1 blank line before a " \
285+
"nested definition, found 0"
285286
else:
286287
yield 0, "E301 expected 1 blank line, found 0"
287288
elif blank_before != 2:

0 commit comments

Comments
 (0)