diff --git a/docs/release_notes.rst b/docs/release_notes.rst index cb3a3278..13c677fb 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -14,6 +14,7 @@ New Features Bug Fixes * Update convention support documentation (#386, #393) +* Detect inner asynchronous functions for D202 (#467) 5.0.2 - January 8th, 2020 --------------------------- diff --git a/src/pydocstyle/checker.py b/src/pydocstyle/checker.py index 696b8bf7..f5b34f32 100644 --- a/src/pydocstyle/checker.py +++ b/src/pydocstyle/checker.py @@ -203,7 +203,7 @@ def check_no_blank_before(self, function, docstring): # def # class. if not ( blanks_after_count == 1 and - re(r"\s+(?:(?:class|def)\s|@)").match(after) + re(r"\s+(?:(?:class|def|async def)\s|@)").match(after) ): yield violations.D202(blanks_after_count) diff --git a/src/tests/test_cases/functions.py b/src/tests/test_cases/functions.py index cbc24268..4431d709 100644 --- a/src/tests/test_cases/functions.py +++ b/src/tests/test_cases/functions.py @@ -29,6 +29,15 @@ def inner(): pass +def func_with_inner_async_func_after(): + """Test a function with inner async function after docstring.""" + + async def inner(): + pass + + pass + + def fake_decorator(decorated): """Fake decorator used to test decorated inner func.""" return decorated @@ -44,6 +53,16 @@ def inner(): pass +def func_with_inner_decorated_async_func_after(): + """Test a function with inner decorated async function after docstring.""" + + @fake_decorator + async def inner(): + pass + + pass + + def func_with_inner_class_after(): """Test a function with inner class after docstring."""