From 204dc6af56ef9cc6ae5adc87dc0ae34822223750 Mon Sep 17 00:00:00 2001 From: Zhang Jie <13131481+j-z10@users.noreply.github.com> Date: Tue, 12 Mar 2024 22:03:50 +0800 Subject: [PATCH] async def function formatting --- autopep8.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/autopep8.py b/autopep8.py index 6b28b8a2..b6bc7e28 100755 --- a/autopep8.py +++ b/autopep8.py @@ -202,7 +202,7 @@ def extended_blank_lines(logical_line, indent_level, previous_logical): """Check for missing blank lines after class declaration.""" - if previous_logical.startswith('def '): + if previous_logical.startswith(('def ', 'async def ')): if blank_lines and pycodestyle.DOCSTRING_REGEX.match(logical_line): yield (0, 'E303 too many blank lines ({})'.format(blank_lines)) elif pycodestyle.DOCSTRING_REGEX.match(previous_logical): @@ -211,7 +211,7 @@ def extended_blank_lines(logical_line, indent_level and not blank_lines and not blank_before and - logical_line.startswith(('def ')) and + logical_line.startswith(('def ', 'async def ')) and '(self' in logical_line ): yield (0, 'E301 expected 1 blank line, found 0') @@ -2914,7 +2914,7 @@ def normalize_multiline(line): This is for purposes of checking syntax. """ - if line.startswith('def ') and line.rstrip().endswith(':'): + if line.startswith(('def ', 'async def ')) and line.rstrip().endswith(':'): return line + ' pass' elif line.startswith('return '): return 'def _(): ' + line