flake8-tidy-imports
A flake8 plugin that helps you write tidier imports.
What it is and what it does
flake8-tidy-imports is a flake8 plugin that enforces import hygiene by detecting three categories of import issues: unnecessary aliases (I250), banned imports (I251), and relative imports (I252). It integrates directly into flake8's linting workflow and reports violations with configurable messages. The plugin is configured via flake8's standard config files and allows you to define which imports should be banned, whether relative imports are allowed, and what messages to show when violations occur.
The plugin supports wildcard patterns in banned-modules, a special {python2to3} directive to ban Python 2 modules with suggested replacements, and fine-grained control over relative imports. It has been actively maintained since 2016 and is classified as Production/Stable with support for Python 3.9 to 3.14.
Use it for:
- Enforce a project-wide ban on deprecated modules and suggest modern replacements during code review.
- Prevent accidental use of relative imports in a codebase that requires absolute imports for clarity.
- Automatically flag unnecessary import aliases during linting to keep imports clean.
- Configure wildcard bans on entire module hierarchies to guide developers away from old code.
- Integrate import style enforcement into CI/CD pipelines via flake8 without additional tools.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A flake8 plugin that detects and reports unnecessary import aliases, banned imports, and relative imports according to configurable rules.
Yes. The plugin is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and installs with minimal friction (one dependency). It solves a real problem—enforcing import discipline—and integrates seamlessly into existing flake8 workflows. Recommended for any project using flake8 that wants to enforce import policies.
Install
flake8-tidy-imports on PyPI
pip
pip install flake8-tidy-importsuv
uv add flake8-tidy-importspoetry
poetry add flake8-tidy-importsInstalling flake8-tidy-imports
Before you install
Low friction: pure Python wheel with only flake8 as a runtime dependency. Actively maintained with last commit 2026-08-13 and latest release 2025-09-08. Supports Python 3.9 to 3.14.
License in practice
MIT license (permissive) places no restrictions on use, modification, or distribution in proprietary or open-source projects.
Quickstart
pip install flake8-tidy-imports
# In setup.cfg or .flake8:
[flake8]
banned-modules =
mock = Use unittest.mock.
# Then run flake8 as normal:
flake8 your_code.py
Requires Python 3.9 or later. If you define flake8's `select` setting, you must add the `I25` prefix to activate the plugin's rules.
Verify before relying
- Whether the suggested rewrites for I250 (unnecessary aliases) are always syntactically correct in all edge cases.
- Performance impact when checking large codebases with many banned-modules entries or wildcard patterns.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — flake8 |
| Maintenance | actively maintained — 340 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 461,480/month — #6,533 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flake8_tidy_imports-4.12.0-py3-none-any.whl
Keywords: flake8_tidy_imports
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
flake8-import-orderA flake8 plugin that enforces import ordering…
copyleft · top 5,000 on PyPI
flake8-isortIntegrates isort into flake8 linting, reporting…
copyleft · top 5,000 on PyPI
flake8-type-checkingA flake8 plugin that identifies which imports…
permissive · top 15,000 on PyPI
flake8-requirementsA flake8 plugin that validates whether imported…
permissive · top 15,000 on PyPI
flake8-pep585A flake8 plugin that detects and flags…
copyleft · top 15,000 on PyPI
flake8-comprehensionsA flake8 plugin that detects and suggests…
permissive · top 5,000 on PyPI
flake8-typing-importsA flake8 plugin that detects unguarded typing…
permissive · top 15,000 on PyPI
absolufy-importsAutomatically converts relative imports to…
permissive · top 15,000 on PyPI
flake8-pieA flake8 plugin that detects code quality…
permissive · top 15,000 on PyPI
flake8-use-pathlibA flake8 plugin that detects uses of os and…
permissive · top 15,000 on PyPI