Skip to content

Commit 67e1ae1

Browse files
authored
Fix when in some cases func to not have attr (#20)
1 parent 3d3c7d0 commit 67e1ae1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

apps/unused_code/unused_code.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@ def is_fixture_autouse(func):
1515
for deco in func.decorator_list:
1616
if not hasattr(deco, "func"):
1717
continue
18-
if deco.func.attr == "fixture" and deco.func.value.id == "pytest":
19-
for _key in deco.keywords:
20-
if _key.arg == "autouse":
21-
return _key.value.s
18+
19+
if getattr(deco.func, "attr", None) and getattr(deco.func, "value", None):
20+
if deco.func.attr == "fixture" and deco.func.value.id == "pytest":
21+
for _key in deco.keywords:
22+
if _key.arg == "autouse":
23+
return _key.value.s
2224

2325

2426
def _iter_functions(tree):
@@ -64,7 +66,9 @@ def is_ignore_function_list(ignore_prefix_list, function):
6466
default=os.path.expanduser("~/.config/python-utility-scripts/config.yaml"),
6567
)
6668
@click.option(
67-
"--exclude-files", help="Provide a comma-separated string or list of files to exclude", type=ListParamType()
69+
"--exclude-files",
70+
help="Provide a comma-separated string or list of files to exclude",
71+
type=ListParamType(),
6872
)
6973
@click.option(
7074
"--exclude-function-prefixes",

0 commit comments

Comments
 (0)