Closed Llandy3d closed 1 year ago
Thanks for the report! I tried to replicate the error, but failed. Even with the regression test executed on several Python versions (https://github.com/jendrikseipp/vulture/pull/284), the error doesn't occur. Could you try to prepare a pull request that fixes the error?
Sorry, I opened this with a rush and copied the wrong snippet. I updated the snippet in the code above, the correct one would be:
from prometheus_client import Histogram
hist = Histogram("name", "description", labelnames=["label1"])
@hist.labels("place1").time()
def myfunc():
pass
I will be away for some time so nothing short term, it will probably require more analysis
Thanks! I put your code into my test branch (#284) and now the error happens for Python 3.10. For older Python versions, the decorator simply raises a SyntaxError, so this needs a version-dependent fix. Would be great if you could take a stab at this when you find the time :-)
Actually I had some time and played around with it, I will be opening a PR soon but I will be able to check comments on it next week!
I tried with python 3.9.12 locally but I still see the AttributeError
🤔
Fixed in #284.
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 theast.Attribute
you can get the iddecorator.id
. When using a decorator from theprometheus_client
for example:after the Attribute you will be finding an
ast.Call
object that won't have the id attribute and raise theAttributeError
. From my understanding this is due to some extra decorating work that the library is doing, but possibly thevulture
tool shouldn't fail with an error.For now this has been solved by ignoring the file with the
--exclude
flagThe traceback: