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

Commit a964dd2

Browse files
committed
fix coverage
1 parent b3a24b5 commit a964dd2

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

flake8_idom_hooks/exhaustive_deps.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ def visit_Call(self, node: ast.Call) -> None:
5252
elif isinstance(called_func, ast.Attribute):
5353
called_func_name = called_func.attr
5454
else: # pragma: no cover
55-
return None
55+
return
5656

5757
if called_func_name not in HOOKS_WITH_DEPS:
58-
return None
58+
return
5959

6060
func: Optional[ast.expr] = None
6161
args: Optional[ast.expr] = None

tests/cases/exhaustive_deps.py

+15
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
# error: ROH101 hook 'use_effect' used outside component or hook definition
2+
use_effect(lambda: x) # no need to check deps outside component/hook
3+
4+
15
@component
26
def check_effects():
37
x = 1
48
y = 2
59

10+
# check that use_state is not treated as having dependencies.
11+
use_state(lambda: x)
12+
613
use_effect(
714
lambda: (
815
# error: ROH202 dependency 'x' of function 'lambda' is not specified in declaration of 'use_effect'
@@ -38,6 +45,14 @@ def check_effects():
3845
[],
3946
)
4047

48+
module.submodule.use_effect(
49+
lambda: (
50+
# error: ROH202 dependency 'x' of function 'lambda' is not specified in declaration of 'use_effect'
51+
x
52+
),
53+
[],
54+
)
55+
4156
use_effect(
4257
lambda: (
4358
# error: ROH202 dependency 'x' of function 'lambda' is not specified in declaration of 'use_effect'

0 commit comments

Comments
 (0)