skillfed

flake8-tidy-imports

A flake8 plugin that helps you write tidier imports.

flake8-tidy-imports v4.12.0 461.5K downloads/30d#6,533 on PyPI74
Permissive license MIT Active released

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-imports

uv

uv add flake8-tidy-imports

poetry

poetry add flake8-tidy-imports

Installing 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

Development Status :: 5 - Production/StableFramework :: Flake8Intended Audience :: DevelopersNatural Language :: EnglishProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Typing :: Typed

Tags

flake8 import lintingdetect unnecessary import aliasesban imports by configurationrelative import checkerimport style enforcementflake8 plugin for importstidy import rules
lintingimport-hygienecode-quality

More Quality Assurance packages