tldr/pages/common/autoflake.md

21 lines
697 B
Markdown
Raw Normal View History

2018-01-02 10:33:12 +00:00
# autoflake
> A tool to remove unused imports and variables from Python code.
2019-04-11 17:29:48 +01:00
> Homepage: <https://github.com/myint/autoflake>.
2018-01-02 10:33:12 +00:00
- Remove unused variables from a single file and display the diff:
`autoflake --remove-unused-variables {{file.py}}`
- Remove unused imports from multiple files and display the diffs:
`autoflake --remove-all-unused-imports {{file1.py}} {{file2.py}} {{file3.py}}`
- Remove unused variables from a file, overwriting the file:
`autoflake --remove-unused-variables --in-place {{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}}`