-
Notifications
You must be signed in to change notification settings - Fork 169
Closed
Description
Hello,
I just wanted to raise awareness about an issue that I mainly encountered when working with the python prometheus client.
The get_decorator_name
function seems to assume that after cycling over the ast.Attribute
you can get the id decorator.id
.
When using a decorator from the prometheus_client
for example:
from prometheus_client import Histogram
hist = Histogram('name', 'description', labelnames=["label1"])
@hist.labels('place1').time()
def myfunc():
...
after the Attribute you will be finding an ast.Call
object that won't have the id attribute and raise the AttributeError
. From my understanding this is due to some extra decorating work that the library is doing, but possibly the vulture
tool shouldn't fail with an error.
For now this has been solved by ignoring the file with the --exclude
flag
The traceback:
Traceback (most recent call last):
File "/usr/local/bin/vulture", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.10/site-packages/vulture/core.py", line 689, in main
vulture.scavenge(config["paths"], exclude=config["exclude"])
File "/usr/local/lib/python3.10/site-packages/vulture/core.py", line 264, in scavenge
self.scan(module_string, filename=module)
File "/usr/local/lib/python3.10/site-packages/vulture/core.py", line 231, in scan
self.visit(node)
File "/usr/local/lib/python3.10/site-packages/vulture/core.py", line 645, in visit
return self.generic_visit(node)
File "/usr/local/lib/python3.10/site-packages/vulture/core.py", line 677, in generic_visit
self.visit(item)
File "/usr/local/lib/python3.10/site-packages/vulture/core.py", line 630, in visit
visitor(node)
File "/usr/local/lib/python3.10/site-packages/vulture/core.py", line 564, in visit_FunctionDef
decorator_names = [
File "/usr/local/lib/python3.10/site-packages/vulture/core.py", line 565, in <listcomp>
utils.get_decorator_name(decorator)
File "/usr/local/lib/python3.10/site-packages/vulture/utils.py", line 69, in get_decorator_name
return "@" + ".".join(reversed(parts))
AttributeError: 'Call' object has no attribute 'id'
Metadata
Metadata
Assignees
Labels
No labels