jendrikseipp / vulture

Find dead Python code
MIT License
3.29k stars 145 forks source link

Help with ignoring decorated method #336

Closed elParaguayo closed 8 months ago

elParaguayo commented 8 months ago

Hi there, I'm struggling to ignore an error flagged by vulture.

In my code I have the following method:

from dbus_next.service import method

...

@method()
def RegisterWindow(self, windowId: "u", menuObjectPath: "o"):  # type: ignore  # noqa: F821, N802, N803
    pass

vulture reports unused variable 'menuObjectPath' (100% confidence). I don't want to change the name as it's part of a spec so I have added the following line to [tool.vulture] in my pyproject.toml file: ignore_decorators = ["@method"]. However, vulture is still reporting the error. I've tried adding parentheses too with the same result.

Have I missed something obvious?

jendrikseipp commented 8 months ago

Vulture just ignores the method name, not the argument names. We're currently debating whether this should be changed in an issue.

elParaguayo commented 8 months ago

I got caught out by a google search which included this "Additionally, the --ignore-decorators option can be used to ignore functions decorated with the given decorator."

Thanks for the reply.

elParaguayo commented 8 months ago

It does actually say that on PyPI so you may want to fix that at some point.

jendrikseipp commented 8 months ago

Good point, thanks! Done.