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

fix: regex to catch inner functions doesn't catch asynchronous ones #467

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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