logo
Free, Micro AI Code Reviews That Run on Git Commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, Micro AI Code Reviews That Run on Git Commit | Product Hunt git-lrc - Free, Micro AI Code Reviews That Run on Git Commit | Product Hunt

Remove Unused Python Imports - Autoflake | Online Free DevTools by Hexmos

Remove unused Python imports and variables with Autoflake. Clean your code automatically and improve readability for easier maintenance. Free online tool, no registration required.

autoflake

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

  • Remove unused variables from a single file and display the diff:

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

  • Remove unused imports from multiple files and display the diffs:

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

  • Remove unused variables from a file, overwriting the file:

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

  • Remove unused variables recursively from all files in a directory, overwriting each file:

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

See Also