autoflake
Removes unused imports and unused variables
Decision gist · record as of 2026-08-14
Yes. autoflake is a lightweight, actively maintained tool with no security vulnerabilities, minimal dependencies, and a permissive MIT license. It solves a real code-quality problem with low friction and is well-suited for both individual developers and teams integrating it into CI/CD workflows.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python >=3.10.
- Low install friction with only 2 runtime dependencies (pyflakes and tomli).
- The project is actively maintained with a recent release on 2026-02-20 and steady commit activity.
License · maintenance · safety
MIT (permissive) — MIT license is permissive, allowing use in commercial and private projects with minimal restrictions.
last release 2026-02-20 (175 days) · last repo commit 2026-07-30 · 953 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 6,494,194 downloads/mo, #1,900 on PyPI
Alternatives
Verify before relying
pip install autoflake
autoflake --in-place --remove-unused-variables example.py- Whether the tool safely handles imports with side effects beyond the documented --imports and # noqa mechanisms.
- Performance characteristics when processing large codebases or using parallel jobs (-j flag).
What it is and what it does
autoflake is a command-line tool that automatically detects and removes unused imports and variables from Python source files. It uses pyflakes to identify dead code and by default only removes unused imports from the standard library, leaving third-party imports untouched unless explicitly configured. This conservative default prevents accidental removal of imports that may have side effects.
The tool is typically used as a standalone formatter or integrated into pre-commit hooks to enforce code cleanliness. It supports configuration via pyproject.toml or setup.cfg, can operate on single files or recursively through directories, and offers fine-grained control over what gets removed—from all unused imports to unused variables to duplicate dictionary keys. It also removes useless pass statements by default.
Use it for
- Run as a pre-commit hook to automatically clean up unused imports before code review.
- Integrate into CI/CD pipelines to check for unused code and fail builds when cleanup is needed.
- Refactor legacy Python codebases to remove accumulated dead imports and variables.
- Configure with --imports to safely remove unused third-party imports in specific projects.
- Use --expand-star-imports to replace wildcard imports with explicit names for clarity.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
autoflake is a lightweight, actively maintained tool with no security vulnerabilities, minimal dependencies, and a permissive MIT license. It solves a real code-quality problem with low friction and is well-suited for both individual developers and teams integrating it into CI/CD workflows.
Install
autoflake on PyPI
Before you install
Low install friction with only 2 runtime dependencies (pyflakes and tomli). The project is actively maintained with a recent release on 2026-02-20 and steady commit activity.
Requires Python >=3.10.
License in practice
MIT license is permissive, allowing use in commercial and private projects with minimal restrictions.
Quickstart
pip install autoflake
autoflake --in-place --remove-unused-variables example.py
Verify before relying
- Whether the tool safely handles imports with side effects beyond the documented --imports and # noqa mechanisms.
- Performance characteristics when processing large codebases or using parallel jobs (-j flag).
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagespyflakestomli |
| Maintenance | Actively maintained 175 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 6,494,194 / month, #1,900 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Environment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyTopic :: Software Development :: Quality Assurance |
Evidence: autoflake-2.3.3-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “remove unused imports python”
- autoflakeautoflake removes unused imports and unused variables from Python…
- creosoteCreosote scans your Python project's source code and dependency…
- pyclnPycln finds and removes unused import statements from Python code,…
Give your agent the search over MCP, or paste the wish link into any chat.
More Quality Assurance packages
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
Ruff is a Python linter and code formatter written in Rust that combines linting, formatting, and code fixing into a single tool, replacing Flake8, Black, isort, and related utilities.
Pexpect spawns and controls interactive console applications by sending input and matching output patterns, automating tasks that would otherwise require manual interaction.
Black reformats Python source code to a consistent style by parsing entire files and rewriting them according to an opinionated, deterministic set of rules, eliminating manual formatting decisions.
pytest-xdist distributes pytest tests across multiple CPU cores or machines to speed up test execution, with the simplest usage being `pytest -n auto` to spawn workers equal to available CPUs.
Install it if your test suite takes long enough that parallelization would save meaningful time.
Validates AWS CloudFormation templates in YAML or JSON format against resource provider schemas and best practices, checking property values and configuration correctness.
Install it if you work with CloudFormation templates.
See also pycln · pyflakes · yesqa · deadcode · pip-autoremove · vulture · autopep8 · creosote · pip-check-reqs · uncalled