Registry / testing / flake8-import-order

flake8-import-order

JSON →
library0.19.2pypypi✓ verified 24d ago

A Flake8 and Pylama plugin that checks the ordering of import statements in Python code. It ensures imports are grouped (standard library, third-party, local) and typically alphabetized within groups, though the exact rules depend on the configured style. The current version is 0.19.2, and it maintains an active release cadence with regular updates.

pip install flake8-import-order
INSTALL
IMPORT
SIG · FLAKE8-IMPORT-ORDE
F
flake8-import-order
testingpythonv0.19.2
Install
1.8s avg
Import
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.19.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 18.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.000s · 19MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

N/A
N/A
flake8-import-order is a plugin for Flake8; it is not typically imported directly in Python code. Its functionality is enabled and configured via Flake8's configuration files (e.g., .flake8, pyproject.toml).

Install the plugin, then configure Flake8 to use a specific import order style and define your application's import names. Run `flake8` on your Python files to see import order violations.

# 1. Create a Python file (e.g., my_module.py): # import os # import pytest # from my_app import utils # import sys # # 2. Create a Flake8 configuration file (e.g., .flake8): # [flake8] # import-order-style = google # application-import-names = my_app,my_other_app # To run the check: # flake8 my_module.py # # Expected output for the example above: # my_module.py:2:1: I100 Your import statements are in the wrong order. # my_module.py:3:1: I201 Missing newline between import groups.
Debug
Known issues
breakingVersion 0.19.0 dropped support for Python 3.7 and 3.8. Ensure your Python environment is 3.9+ when upgrading to 0.19.0 or newer.
fix
Upgrade Python to 3.9 or newer, or pin `flake8-import-order<0.19.0` for older Python versions.
affects: 0.19.0+
gotchaFor correct classification of local application imports, you *must* configure `application-import-names` and optionally `application-package-names` in your Flake8 configuration. Without this, your own modules might be incorrectly flagged as third-party.
fix
Add `application-import-names = your_app_name1,your_app_name2` to your Flake8 config (e.g., `.flake8` or `pyproject.toml`).
affects: All versions
gotchaThe standard library module list used for classification is vendored and static across all Python versions. This might lead to incorrect classifications if your specific Python environment has a different set of standard library modules (e.g., very old or very new Python versions).
fix
Be aware of this limitation; for edge cases, manual `noqa` comments might be necessary.
affects: All versions
gotchaThe plugin primarily checks module-scope imports. Conditional imports (e.g., inside `if` blocks) are generally ignored, with the exception of imports within `if TYPE_CHECKING:` blocks.
fix
Structure your code to place imports at module scope where possible. Manual review is needed for complex conditional import patterns.
affects: All versions
Upgrade
Version history
0.19.2latest on PyPI · released Jun 24, 2025
Audit
Dependencies
flake8requiredThis library is a plugin for Flake8 and requires it to function.
pylamaoptionalCan also integrate with Pylama as an alternative code audit tool.
pycodestyleoptionalA core dependency of Flake8, often implicitly installed.
Agent activity
9 hits · last 30 days
node
8
Resources