---
name: "autoflake"
section: "1"
platform: "linux"
package: "autoflake"
version: "2.3.1-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/autoflake"
---

# autoflake(1)

removes unused imports and unused variables in Python code

## NAME

autoflake - removes unused imports and unused variables in Python code

## SYNOPSIS

**autoflake** \[-h\] \[-c \| -cd\] \[--imports IMPORTS \| --remove-all-unused-imports\] \[-r\] \[-j n\] \[--exclude globs\] \[--expand-star-imports\] \[--ignore-init-module-imports\] \[--remove-duplicate-keys\] \[--remove-unused-variables\] \[--remove-rhs-for-unused-variables\] \[--ignore-pass-statements\] \[--ignore-pass-after-docstring\] \[--version\] \[--quiet\] \[-v\] \[--stdin-display-name STDIN\_DISPLAY\_NAME\] \[--config CONFIG\_FILE\] \[-i \| -s\] files \[files ...\]

- **files**

  files to format

## DESCRIPTION

Removes unused imports and unused variables as reported by pyflakes.

## OPTIONS

- **-c**, **--check**

  return error code if changes are needed

- **-cd**, **--check-diff**

  return error code if changes are needed, also display file diffs

- **--imports** *IMPORTS*

  by default, only unused standard library imports are removed; specify a comma- separated list of additional modules/packages

- **--remove-all-unused-imports**

  remove all unused imports (not just those from the standard library)

- **-r**, **--recursive**

  drill down directories recursively

- **-j** *n*, **--jobs** *n*

  number of parallel jobs; match CPU count if value is 0 (default: 0)

- **--exclude** *globs*

  exclude file/directory names that match these comma-separated globs

- **--expand-star-imports**

  expand wildcard star imports with undefined names; this only triggers if there is only one star import in the file; this is skipped if there are any uses of \`\_\_all\_\_\` or \`del\` in the file

- **--ignore-init-module-imports**

  exclude \_\_init\_\_.py when removing unused imports

- **--remove-duplicate-keys**

  remove all duplicate keys in objects

- **--remove-unused-variables**

  remove unused variables

- **--remove-rhs-for-unused-variables**

  remove RHS of statements when removing unused variables (unsafe)

- **--ignore-pass-statements**

  ignore all pass statements

- **--ignore-pass-after-docstring**

  ignore pass statements after a newline ending on '"""'

- **--version**

  show program's version number and exit

- **--quiet**

  Suppress output if there are no issues

- **-v**, **--verbose**

  print more verbose logs (you can repeat \`-v\` to make it more verbose)

- **--stdin-display-name** *STDIN\_DISPLAY\_NAME*

  the name used when processing input from stdin

- **--config** *CONFIG\_FILE*

  Explicitly set the config file instead of auto determining based on file location

- **-i**, **--in-place**

  make changes to files instead of printing diffs

- **-s**, **--stdout**

  print changed text to stdout. defaults to true when formatting stdin, or to false otherwise

## AUTHOR

```
Steven Myint
```

```
git@stevenmyint.com
```

## DISTRIBUTION

The latest version of autoflake may be downloaded from ⟨https://github.com/PyCQA/autoflake⟩
