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

Commit 91b93f2

Browse files
committed
only check calls where hook is the callee
1 parent f16aeaa commit 91b93f2

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

flake8_idom_hooks/rules_of_hooks.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,14 @@ def visit_FunctionDef(self, node: ast.FunctionDef) -> None:
4747

4848
def visit_Call(self, node: ast.Call) -> None:
4949
with set_current(self, call=node):
50-
self.generic_visit(node)
50+
self.visit(node.func)
51+
for a in node.args:
52+
self.visit(a)
53+
for kw in node.keywords:
54+
self.visit(kw)
5155

5256
def _visit_hook_usage(self, node: ast.Name | ast.Attribute) -> None:
53-
if self._current_call:
57+
if self._current_call is not None:
5458
self._check_if_propper_hook_usage(node)
5559

5660
visit_Attribute = _visit_hook_usage

tests/cases/hook_usage.py

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ def HookInIfNoCall():
77
if True:
88
# Ok, hook was not called
99
use_state
10+
# Also ok, hook itself was not called
11+
func(use_state)
1012

1113

1214
@component

0 commit comments

Comments
 (0)