jendrikseipp / vulture

Find dead Python code
MIT License
3.38k stars 148 forks source link

Mark deleted variables as used #278

Closed jendrikseipp closed 2 years ago

jendrikseipp commented 2 years ago

Hello guys, for overridden functions and unused arguments, can the vulture follow the same rules as pylint and other tools.

It is described here: https://stackoverflow.com/a/14836005

And this is specified as the suggested solution by PyLint: http://pylint-messages.wikidot.com/messages:w0613

Currently I am trying to use del but vulture is still reporting the variable as unused

Originally posted by @sshishov in https://github.com/jendrikseipp/vulture/issues/235#issuecomment-1105162434

jendrikseipp commented 2 years ago

Thanks for the report @sshishov! I agree that del a should mark the a variable as used.

Here is a little test case for this:

def foo(a):
    del a
    return 1

foo(2)

To implement this, one would need to count Name(id='a', ctx=Del()) in the abstract syntax tree as a usage of variable a. Pull requests welcome :-)

RJ722 commented 2 years ago

@jendrikseipp let's close this.

jendrikseipp commented 2 years ago

Thanks for the reminder! Yes, this has been fixed in the meantime.