How do I get all the unused variables and functions in my Python project?
How do I get all the unused variables and functions in my Python project?
Use pylint!
Install it with
pip install pylint
And run it on your project files
find . -name "*.py" | xargs pylint
The above command will find all Python source files in your project and feed them using xargs to pylint. Pylint with output a report containing all lint warnings including unused variables.
Can use vulture. These come in handy.It can't catch everything due to Python's dynamic nature, but can identify a lot without using the test suite completely.