How can I check if an imported library is being used in a python script?

The title says it all. I am cleaning up python scripts I have written. Sometimes when writing scripts, I tried one library just to replace it, or didn't use it later.

I would like to be able to check if the imported library is actually being used in the script later. Ideally I would do this without having to comment out the import line and run it every time I look for errors.

Does anyone know of a resource or script / library that checks this? Or what about some other script cleanup tips to share with others?

Thanks Mike

+3


source to share


1 answer


Try Pinteron linter, they'll do it for you for example flake8

. Install with pip install flake8

and run by calling flake8

the root folder of your project.



+1


source







All Articles