autoflake

Remove unused imports and variables from Python code. More information: https://github.com/myint/autoflake.

autoflake --remove-unused-variables path/to/file.py

autoflake --remove-all-unused-imports path/to/file1.py path/to/file2.py ...

autoflake --remove-unused-variables --in-place path/to/file.py

autoflake --remove-unused-variables --in-place --recursive path/to/directory