AUTOFLAKE(1)
β¨ AUTO FLAKE β¨ (that's AUTOFLAKE(1) bestie, a generated Python manual, and no it's not about cereal)
okay so picture this: your Python file is a mess, you've got imports you literally never use, variables that just vibe there doing nothing, and pyflakes is staring at you π. autoflake is the friend who comes over, opens the closet, and goes "girl. we're getting rid of this." it's a whole glow-up for your code and honestly? iconic. π
π NAME π
autoflake β removes unused imports and unused variables in Python code.
periodt.
π¦ 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
so basically: files is where you point it, and everything else is optional seasoning β¨
πΈ DESCRIPTION πΈ
autoflake removes unused imports and unused variables, based on what pyflakes reports. that's it. that's the whole gig. it reads what pyflakes is yelling about and then quietly, calmly, does the deleting for you π§Ήπ¦
π OPTIONS π
-c,--checkβ don't fix anything, just snitch: returns an error code if changes are needed π-cd,--check-diffβ same snitching energy, but it also shows you the file diffs so you can see exactly what it would change π--imports IMPORTSβ by default it only yeets unused imports that come from the standard library. wanna include more? pass a comma-separated list of extra modules/packages and it'll consider those too π«--remove-all-unused-importsβ listen, be brave: remove ALL unused imports, not just the standard library ones π₯-r,--recursiveβ drill down through directories recursively, like a girl who checks every last drawer ποΈπ-j n,--jobs nβ number of parallel jobs; if the value is0it matches your CPU count (default:0) β‘--exclude globsβ skip any file/directory names matching these comma-separated globs. not today, not ever π«--expand-star-importsβ expands wildcard star imports using the undefined names. important caveats, bestie: this only triggers if there's only one star import in the file, and it's skipped entirely if the file uses__all__ordelanywhere π--ignore-init-module-importsβ leave__init__.pyout of the unused-import cleanup π‘οΈ--remove-duplicate-keysβ removes all duplicate keys in objects π--remove-unused-variablesβ removes unused variables π«₯--remove-rhs-for-unused-variablesβ removes the RHS of statements when removing unused variables. β οΈ this one is unsafe, fr fr β say it with me, UN-SAFE β οΈ--ignore-pass-statementsβ ignores allpassstatements π--ignore-pass-after-docstringβ ignorespassstatements that come after a newline ending on'"""'π--versionβ shows the program's version number and exits, like a little name-drop π--quietβ suppresses output if there are no issues. if nothing's wrong, we don't need the commentary π€«-v,--verboseβ prints more verbose logs. and yes you can repeat-vto make it even more verbose, stack them like little gossip levels π£οΈ--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 it based on file location π-i,--in-placeβ actually makes the changes to your files instead of printing diffs. commit. π-s,--stdoutβ prints the changed text to stdout. it defaults totruewhen formatting stdin, and tofalseotherwise π
π AUTHOR π
Steven Myint β git@stevenmyint.com π
π DISTRIBUTION π
the latest version of autoflake may be downloaded from https://github.com/PyCQA/autoflake π«Ά
okay that's the whole page bestie, and that's on autoflake, generated Python manual, from 2026-02-20 β go forth and delete some unused imports, you absolute icon β¨πππ¦πΈπ
π¦ where this page comes from
- ubuntu stonking: autoflake 2.3.3-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms