diff --git a/flake8_idom_hooks/rules_of_hooks.py b/flake8_idom_hooks/rules_of_hooks.py index c8ac79d..acb6b64 100644 --- a/flake8_idom_hooks/rules_of_hooks.py +++ b/flake8_idom_hooks/rules_of_hooks.py @@ -47,10 +47,14 @@ def visit_FunctionDef(self, node: ast.FunctionDef) -> None: def visit_Call(self, node: ast.Call) -> None: with set_current(self, call=node): - self.generic_visit(node) + self.visit(node.func) + for a in node.args: + self.visit(a) + for kw in node.keywords: + self.visit(kw) def _visit_hook_usage(self, node: ast.Name | ast.Attribute) -> None: - if self._current_call: + if self._current_call is not None: self._check_if_propper_hook_usage(node) visit_Attribute = _visit_hook_usage diff --git a/tests/cases/hook_usage.py b/tests/cases/hook_usage.py index f08509a..866c546 100644 --- a/tests/cases/hook_usage.py +++ b/tests/cases/hook_usage.py @@ -7,6 +7,8 @@ def HookInIfNoCall(): if True: # Ok, hook was not called use_state + # Also ok, hook itself was not called + func(use_state) @component