1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-29 23:24:55 +02:00
tldr/pages/common/autoflake.md

21 lines
724 B
Markdown
Raw Normal View History

2018-01-02 02:33:12 -08:00
# autoflake
> A tool to remove unused imports and variables from Python code.
> More information: <https://github.com/myint/autoflake>.
2018-01-02 02:33:12 -08:00
- Remove unused variables from a single file and display the diff:
2023-05-01 10:02:00 +05:30
`autoflake --remove-unused-variables {{path/to/file.py}}`
2018-01-02 02:33:12 -08:00
- Remove unused imports from multiple files and display the diffs:
2023-05-01 10:02:00 +05:30
`autoflake --remove-all-unused-imports {{path/to/file1.py path/to/file2.py ...}}`
2018-01-02 02:33:12 -08:00
- Remove unused variables from a file, overwriting the file:
2023-05-01 10:02:00 +05:30
`autoflake --remove-unused-variables --in-place {{path/to/file.py}}`
2018-01-02 02:33:12 -08:00
- Remove unused variables recursively from all files in a directory, overwriting each file:
`autoflake --remove-unused-variables --in-place --recursive {{path/to/directory}}`