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

Commit

Permalink
fix coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
rmorshea committed Sep 5, 2022
1 parent b3a24b5 commit a964dd2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flake8_idom_hooks/exhaustive_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def visit_Call(self, node: ast.Call) -> None:
elif isinstance(called_func, ast.Attribute):
called_func_name = called_func.attr
else: # pragma: no cover
return None
return

if called_func_name not in HOOKS_WITH_DEPS:
return None
return

func: Optional[ast.expr] = None
args: Optional[ast.expr] = None
Expand Down
15 changes: 15 additions & 0 deletions tests/cases/exhaustive_deps.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# error: ROH101 hook 'use_effect' used outside component or hook definition
use_effect(lambda: x) # no need to check deps outside component/hook


@component
def check_effects():
x = 1
y = 2

# check that use_state is not treated as having dependencies.
use_state(lambda: x)

use_effect(
lambda: (
# error: ROH202 dependency 'x' of function 'lambda' is not specified in declaration of 'use_effect'
Expand Down Expand Up @@ -38,6 +45,14 @@ def check_effects():
[],
)

module.submodule.use_effect(
lambda: (
# error: ROH202 dependency 'x' of function 'lambda' is not specified in declaration of 'use_effect'
x
),
[],
)

use_effect(
lambda: (
# error: ROH202 dependency 'x' of function 'lambda' is not specified in declaration of 'use_effect'
Expand Down

0 comments on commit a964dd2

Please sign in to comment.