From 833cd5244b3887125abcfa1b281be741b184a2d7 Mon Sep 17 00:00:00 2001 From: rmorshea Date: Thu, 6 Oct 2022 23:10:55 -0700 Subject: [PATCH] check case of async func def --- flake8_idom_hooks/rules_of_hooks.py | 8 ++++++++ tests/cases/hook_usage.py | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/flake8_idom_hooks/rules_of_hooks.py b/flake8_idom_hooks/rules_of_hooks.py index 8280a76..b216237 100644 --- a/flake8_idom_hooks/rules_of_hooks.py +++ b/flake8_idom_hooks/rules_of_hooks.py @@ -49,6 +49,14 @@ def visit_FunctionDef(self, node: ast.FunctionDef) -> None: ): self.generic_visit(node) + def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None: + with set_current( + self, + function=node, + early_return=None, + ): + self.generic_visit(node) + def visit_Call(self, node: ast.Call) -> None: with set_current(self, call=node): self.visit(node.func) diff --git a/tests/cases/hook_usage.py b/tests/cases/hook_usage.py index 3595911..317c123 100644 --- a/tests/cases/hook_usage.py +++ b/tests/cases/hook_usage.py @@ -219,3 +219,8 @@ def regression_check(): def effect(): # this return caused false passitive early return error in use_effect usage return cleanup + + @use_effect + async def effect(): + # this return caused false passitive early return error in use_effect usage + return cleanup