A Flake8 plugin that flags likely bugs and questionable design patterns that pyflakes and pycodestyle don't check.
PyCQA/flake8-import-order
A flake8 and Pylama plugin that checks whether Python imports are grouped and ordered according to a chosen style guide.
- Stars
- 279
- Forks
- 72
- Open issues
- 15
- Last commit
- 4 days ago
What is it?
flake8-import-order is a linter plugin for flake8 and Pylama that checks only the grouping and ordering of Python import statements. It does not check other aspects of imports. Standard library imports come first, then third-party packages, then local packages, and each group is alphabetized, though the exact rules depend on the selected style.
The plugin adds four warnings: I100 and I101 for out-of-order imports and out-of-order names in a from-import, and I201 and I202 for missing or extra blank lines between import groups. It ships with several built-in styles, including cryptography (the default), google, smarkets, appnexus, edited, pycharm, and pep8, which enforces grouping without ordering within groups. Projects can declare their own application and package names through configuration options.
Custom styles can be added by subclassing the Style class and registering it through setuptools entry points.
Key features
- 01Checks import grouping and ordering for flake8 and Pylama.
- 02Provides four warning codes covering order and blank-line issues.
- 03Includes built-in styles such as cryptography, google, smarkets, and pep8.
- 04Lets projects configure local application and package names.
- 05Supports custom styles via subclassing and entry points.
Use cases
- Enforcing a consistent import layout across a Python codebase in CI.
- Matching a team's import style guide such as Google's or a project-specific convention.
- Adding import order checks to an existing flake8 linting setup.
Things to know
- Licensed under LGPL-3.0, a copyleft license with conditions on redistribution.
- Checks only module-scope imports; conditional imports are ignored except under TYPE_CHECKING.
- Ordering is checked only between adjacent imports, so some out-of-order imports may not be reported.
In collections
Topics
FAQ
- What is flake8-import-order?
- A flake8 and Pylama plugin that checks whether Python imports are grouped and ordered according to a chosen style guide. flake8-import-order is a linter plugin for flake8 and Pylama that checks only the grouping and ordering of Python import statements. It does not check other aspects of imports. Standard library imports come first, then third-party packages, then local packages, and each group is alphabetized, though the exact rules depend on the selected style.
- Is flake8-import-order free to use? What license does it have?
- flake8-import-order is open source under the LGPL-3.0 license. Check the license terms before using it in commercial products.
- Is flake8-import-order still maintained?
- Actively maintained. The last commit to flake8-import-order was on Nov 3, 2026.
- What can I use flake8-import-order for?
- Enforcing a consistent import layout across a Python codebase in CI. Matching a team's import style guide such as Google's or a project-specific convention. Adding import order checks to an existing flake8 linting setup.
- Where can I get flake8-import-order?
- The source code and installation instructions are on GitHub: https://github.com/PyCQA/flake8-import-order
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Python linter that wraps PyFlakes, pycodestyle and McCabe into one command, with support for third-party plugins.
A single-file Python checker that tests code against the style conventions of PEP 8, using only the standard library.
A Python tool that computes McCabe cyclomatic complexity for functions and runs as a flake8 plugin to flag overly complex code.
A flake8 plugin that flags Python code which can be rewritten in a simpler form, such as merging isinstance calls or replacing if-blocks with ternaries.
Command-line tool and flake8 plugin that enforces shared config settings across multiple projects, and can fix config files automatically.