Skip to content

Commit 001a0ce

Browse files
authored
Merge pull request #556 from markpeek/markpeek-async-def
Report E302 for blank lines before an "async def"
2 parents 4438622 + 72acd6f commit 001a0ce

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pycodestyle.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,12 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number,
250250
Use blank lines in functions, sparingly, to indicate logical sections.
251251
252252
Okay: def a():\n pass\n\n\ndef b():\n pass
253+
Okay: def a():\n pass\n\n\nasync def b():\n pass
253254
Okay: def a():\n pass\n\n\n# Foo\n# Bar\n\ndef b():\n pass
254255
255256
E301: class Foo:\n b = 0\n def bar():\n pass
256257
E302: def a():\n pass\n\ndef b(n):\n pass
258+
E302: def a():\n pass\n\nasync def b(n):\n pass
257259
E303: def a():\n pass\n\n\n\ndef b(n):\n pass
258260
E303: def a():\n\n\n\n pass
259261
E304: @decorator\n\ndef a():\n pass
@@ -266,7 +268,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number,
266268
yield 0, "E304 blank lines found after function decorator"
267269
elif blank_lines > 2 or (indent_level and blank_lines == 2):
268270
yield 0, "E303 too many blank lines (%d)" % blank_lines
269-
elif logical_line.startswith(('def ', 'class ', '@')):
271+
elif logical_line.startswith(('def ', 'async def', 'class ', '@')):
270272
if indent_level:
271273
if not (blank_before or previous_indent_level < indent_level or
272274
DOCSTRING_REGEX.match(previous_logical)):

testsuite/E30.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ def a():
4444
def b():
4545
pass
4646
#:
47+
#: E302:4:1
48+
def a():
49+
pass
4750

51+
async def b():
52+
pass
53+
#:
4854

4955
#: E303:5:1
5056
print

0 commit comments

Comments
 (0)