Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 91764b3

Browse files
authored
Detect inner asynchronous functions for D202 exemption (#467)
* fix: regex to catch inner functions doesn't catch asynchronous ones * add release note * release notes: add D202 precision
1 parent e5bffda commit 91764b3

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

docs/release_notes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ New Features
1414
Bug Fixes
1515

1616
* Update convention support documentation (#386, #393)
17+
* Detect inner asynchronous functions for D202 (#467)
1718

1819
5.0.2 - January 8th, 2020
1920
---------------------------

src/pydocstyle/checker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def check_no_blank_before(self, function, docstring): # def
203203
# class.
204204
if not (
205205
blanks_after_count == 1 and
206-
re(r"\s+(?:(?:class|def)\s|@)").match(after)
206+
re(r"\s+(?:(?:class|def|async def)\s|@)").match(after)
207207
):
208208
yield violations.D202(blanks_after_count)
209209

src/tests/test_cases/functions.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ def inner():
2929
pass
3030

3131

32+
def func_with_inner_async_func_after():
33+
"""Test a function with inner async function after docstring."""
34+
35+
async def inner():
36+
pass
37+
38+
pass
39+
40+
3241
def fake_decorator(decorated):
3342
"""Fake decorator used to test decorated inner func."""
3443
return decorated
@@ -44,6 +53,16 @@ def inner():
4453
pass
4554

4655

56+
def func_with_inner_decorated_async_func_after():
57+
"""Test a function with inner decorated async function after docstring."""
58+
59+
@fake_decorator
60+
async def inner():
61+
pass
62+
63+
pass
64+
65+
4766
def func_with_inner_class_after():
4867
"""Test a function with inner class after docstring."""
4968

0 commit comments

Comments
 (0)