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

Commit

Permalink
Detect inner asynchronous functions for D202 exemption (#467)
Browse files Browse the repository at this point in the history
* fix: regex to catch inner functions doesn't catch asynchronous ones

* add release note

* release notes: add D202 precision
  • Loading branch information
matthieucan committed Apr 29, 2020
1 parent e5bffda commit 91764b3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/release_notes.rst
Expand Up @@ -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
---------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/pydocstyle/checker.py
Expand Up @@ -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)

Expand Down
19 changes: 19 additions & 0 deletions src/tests/test_cases/functions.py
Expand Up @@ -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
Expand All @@ -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."""

Expand Down

0 comments on commit 91764b3

Please sign in to comment.