← 返回命令列表

Linux command

autoflake 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Remove

autoflake --in-place --remove-unused-variables [file.py]

Example

autoflake --in-place --remove-all-unused-imports -r [.]

Check

autoflake --check [file.py]

Example

autoflake --in-place --remove-unused-variables --remove-all-unused-imports [file.py]

说明

autoflake removes unused imports and variables from Python code. It helps keep code clean by eliminating dead code automatically. The tool uses static analysis to identify unused elements and can modify files in place or report issues.

参数

--in-place
Modify files directly
--remove-unused-variables
Remove unused variables
--remove-all-unused-imports
Remove all unused imports
--remove-duplicate-keys
Remove duplicate dictionary keys
--check
Return error if changes needed (CI mode)
-r, --recursive
Process directories recursively
--exclude _pattern_
Exclude files matching pattern
--imports _modules_
Additional modules to remove

FAQ

What is the autoflake command used for?

autoflake removes unused imports and variables from Python code. It helps keep code clean by eliminating dead code automatically. The tool uses static analysis to identify unused elements and can modify files in place or report issues.

How do I run a basic autoflake example?

Run `autoflake --in-place --remove-unused-variables [file.py]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --in-place do in autoflake?

Modify files directly