From 1d9837421e138776945b7c1d7a13e7364b1f2cfe Mon Sep 17 00:00:00 2001 From: Matthieu Caneill Date: Tue, 28 Apr 2020 17:23:25 +0200 Subject: [PATCH 1/3] fix: regex to catch inner functions doesn't catch asynchronous ones --- src/pydocstyle/checker.py | 2 +- src/tests/test_cases/functions.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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.""" From 2cee662ab007260d729bcd82dc40d3374c2687ac Mon Sep 17 00:00:00 2001 From: Matthieu Caneill Date: Tue, 28 Apr 2020 17:28:17 +0200 Subject: [PATCH 2/3] add release note --- docs/release_notes.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index cb3a3278..dcbed4d7 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 (#467) 5.0.2 - January 8th, 2020 --------------------------- From e0125cab8feae4efe49f649a800271029b59d231 Mon Sep 17 00:00:00 2001 From: Matthieu Caneill Date: Wed, 29 Apr 2020 16:48:31 +0200 Subject: [PATCH 3/3] release notes: add D202 precision --- docs/release_notes.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/release_notes.rst b/docs/release_notes.rst index dcbed4d7..13c677fb 100644 --- a/docs/release_notes.rst +++ b/docs/release_notes.rst @@ -14,7 +14,7 @@ New Features Bug Fixes * Update convention support documentation (#386, #393) -* Detect inner asynchronous functions (#467) +* Detect inner asynchronous functions for D202 (#467) 5.0.2 - January 8th, 2020 ---------------------------