Skip to content
This repository has been archived by the owner on Jan 15, 2025. It is now read-only.

Commit

Permalink
check case of async func def
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorshea committed Oct 7, 2022
1 parent 6c5abe7 commit 833cd52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions flake8_idom_hooks/rules_of_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions tests/cases/hook_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 comments on commit 833cd52

@Archmonger
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

false "passitive"?

😁

@rmorshea
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOL, was a bit lazy last night fixing this up

Please sign in to comment.