Flake8 meet isort
Use isort to check if the imports on your python files are sorted the way you expect.
.isort.cfg to define how you want your imports sorted and run flake8 as you usually do.
See isort documentation for
.isort.cfg available options.
Install with pip:
$ pip install flake8-isort
Since version 1.0 a check for an
.isort.cfg file is done,
since version 1.1
setup.cfg is also checked for an
This potentially avoids to lint a project that has no formal definition of how import should be sorted.
--no-isort-config command line switch,
no-isort-config flake8 configuration option it can be disabled.
Since version 2.6 we introduce new
It is used to show verbose multi-line output from
By default it is turned off.
|I001||isort found an import in the wrong position|
|I002||no configuration found (.isort.cfg or [isort] in configs)|
|I003||isort expected 1 blank line in imports, found 0|
|I004||isort found an unexpected blank line in imports|
|I005||isort found an unexpected missing import|
- Python 2.7, 3.5, 3.6, pypy or pypy3
Relation to flake8-import-order
As an alternative to this flake8 plugin, there's flake8-import-order that could be worth checking out. In contrast to this plugin that defers all logic to isort, the flake8-import-order comes bundled with it's own logic.
flake8-import-order comes with a few predefined set of styles meanwhile this plugin can be customized a bit more. But the biggest difference could lie in that flake8-isort actually has the corresponding sorting engine isort that can sort the import orders of your existing python files. Meanwhile flake8-import-order has no such corresponding tool, hence big existing projects who want to adopt either would get a more automized experience choosing flake8-isort.