I remember when I was developing in C++ or Java, the compiler usually complains for unused methods, functions or imports. In my Django project, I have a bunch of Python fil
Have a look at PyChecker. It is a debugging tool and able to find unused variables and modules.
You can use the following user setting:
"python.linting.pylintEnabled": true,
"python.linting.pylintArgs": [
"--enable=W0614"
]
But I think, you'll need to go through all files yourself and hit "save".
Importchecker is a commandline utility to find unused imports in Python modules.
Use a tool like pylint which will signal these code defects (among a lot of others).
Doing these kinds of 'pre-runtime' checks is hard in a language with dynamic typing, but pylint does a terrific job at catching these typos / leftovers from refactoring etc ...
autoflake is an improved version of pyflakes with additional options. It uses pyflakes under the hood, I would recommend to use it instead of using pyflakes directly.
I agree with using PyFlakes. It's like linting, but it excludes styling errors.
UPDATE
How to run: pyflakes <your python file>
or pyflakes <your folder containing python files>
BE CAREFUL!!!
If you run it just with command pyflakes
, it takes a really long time like it is never-ending. My hypothesis is it is trying to check every python file in your machine/folder when you call it that way.