2020-11-04 14:12:56 -06:00
|
|
|
# autoflake
|
|
|
|
|
2021-08-02 04:41:09 -04:00
|
|
|
> 一个工具,用于检查 Python 代码中未被使用的引入和变量。
|
2021-08-31 09:13:49 +02:00
|
|
|
> 更多信息:<https://github.com/myint/autoflake>.
|
2020-11-04 14:12:56 -06:00
|
|
|
|
2022-03-27 07:25:15 +02:00
|
|
|
- 移除指定文件中未使用的变量,并展示 diff:
|
2020-11-04 14:12:56 -06:00
|
|
|
|
2023-05-01 10:02:00 +05:30
|
|
|
`autoflake --remove-unused-variables {{路径/到/文件.py}}`
|
2020-11-04 14:12:56 -06:00
|
|
|
|
2022-03-27 07:25:15 +02:00
|
|
|
- 移除多个文件中未使用的引入,并展示 diffs:
|
2020-11-04 14:12:56 -06:00
|
|
|
|
2023-07-03 07:44:05 +05:30
|
|
|
`autoflake --remove-all-unused-imports {{路径/到/文件1.py 路径/到/文件2.py ...}}`
|
2020-11-04 14:12:56 -06:00
|
|
|
|
2021-08-02 04:41:09 -04:00
|
|
|
- 移除未被使用的变量,并覆盖更新:
|
2020-11-04 14:12:56 -06:00
|
|
|
|
2023-05-01 10:02:00 +05:30
|
|
|
`autoflake --remove-unused-variables --in-place {{路径/到/文件.py}}`
|
2020-11-04 14:12:56 -06:00
|
|
|
|
2021-08-02 04:41:09 -04:00
|
|
|
- 递归地移除指定文件夹下层所有文件中未使用的变量,并覆盖更新:
|
2020-11-04 14:12:56 -06:00
|
|
|
|
|
|
|
`autoflake --remove-unused-variables --in-place --recursive {{路径/到/目录}}`
|