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

Commit 24684a7

Browse files
committed
py37 compat
1 parent d3d42f8 commit 24684a7

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

flake8_idom_hooks/exhaustive_deps.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ def _get_dependency_names_from_expression(
141141
)
142142
return dep_names
143143
elif not (
144-
isinstance(dependency_expr, ast.Constant) and dependency_expr.value is None
144+
isinstance(dependency_expr, (ast.Constant, ast.NameConstant))
145+
and dependency_expr.value is None
145146
):
146147
self._save_error(
147148
201,

flake8_idom_hooks/flake8_plugin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ class Plugin:
1414
name = __name__
1515
version = __version__
1616

17+
options: Namespace = Namespace()
18+
1719
@classmethod
1820
def add_options(cls, option_manager: OptionManager) -> None:
1921
option_manager.add_option(
@@ -34,5 +36,7 @@ def __init__(self, tree: ast.Module) -> None:
3436
def run(self) -> list[tuple[int, int, str, type[Plugin]]]:
3537
return [
3638
error + (self.__class__,)
37-
for error in run_checks(self._tree, self.options.exhaustive_hook_deps)
39+
for error in run_checks(
40+
self._tree, getattr(self.options, "exhaustive_hook_deps", False)
41+
)
3842
]

flake8_idom_hooks/run.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import ast
44

5+
from .utils import ErrorVisitor
56
from .exhaustive_deps import ExhaustiveDepsVisitor
67
from .rules_of_hooks import RulesOfHooksVisitor
78

@@ -10,7 +11,7 @@ def run_checks(
1011
tree: ast.Module,
1112
exhaustive_hook_deps: bool,
1213
) -> list[tuple[int, int, str]]:
13-
visitor_types = [RulesOfHooksVisitor]
14+
visitor_types: list[type[ErrorVisitor]] = [RulesOfHooksVisitor]
1415
if exhaustive_hook_deps:
1516
visitor_types.append(ExhaustiveDepsVisitor)
1617

requirements/lint.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
flake8 >=3.7
22
black
33
mypy
4+
types-setuptools

0 commit comments

Comments
 (0)