Skip to main content

Flake8 and pylama plugin that checks the ordering of import statements.

Project description

flake8-import-order
===================

[![Build
Status](https://travis-ci.org/public/flake8-import-order.png?branch=master)](https://travis-ci.org/public/flake8-import-order)

A [flake8](http://flake8.readthedocs.org/en/latest/) and
[Pylama](https://github.com/klen/pylama) plugin that checks the ordering of
your imports.

In general stdlib comes first, then 3rd party, then local packages, and that
each group is indivudually alphabetized, see Configuration section for details.

It will not check anything else about the imports. Merely that they are grouped
and ordered correctly.

This plugin is under somewhat active development and is heavily influenced by
the personal preferences of the developers of
[cryptography](https://github.com/pyca/cryptography). Expect seemingly random
changes and configuration changes as we figure out how it should work.

Warnings
--------

This package adds 3 new flake8 warnings

* ``I100``: Your import statements are in the wrong order.
* ``I101``: The names in your from import are in the wrong order.
* ``I201``: Missing newline between sections or imports.

Configuration
-------------

You will want to set the `application-import-names` option to a comma separated
list of names that should be considered local to your application. These will
be used to help categorise your import statements into the correct groups.

`import-order-style` controls what style the plugin follows (`cryptography` is
the default):
* `cryptography` - see an [example](https://github.com/public/flake8-import-order/blob/master/tests/test_cases/complete.py)
* `google` - style described in [Google Style
Guidelines](http://google-styleguide.googlecode.com/svn/trunk/pyguide.html?showone=Imports_formatting#Imports_formatting),
see an [example](https://github.com/public/flake8-import-order/blob/master/tests/test_cases/complete_google.py)

Limitations
-----------

Currently these checks are limited to module scope imports only. Conditional
imports in module scope will also be ignored. The classification of an import
as being non-stdlib of some kind depends on that package actually being
installed.

``I103`` only checks that groups of imports are not consecutive and only takes
into account the first line of each import statement. This means that
multi-line from imports, comments between imports and so on may cause this
error not to be raised correctly in all situations. This restriction is due to
the data provided by the stdlib ``ast`` module.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

flake8-import-order-0.6.tar.gz (8.0 kB view details)

Uploaded Source

flake8-import-order-0.6.linux-x86_64.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

flake8_import_order-0.6-py2.py3-none-any.whl (11.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file flake8-import-order-0.6.tar.gz.

File metadata

File hashes

Hashes for flake8-import-order-0.6.tar.gz
Algorithm Hash digest
SHA256 a768f7ded705356cf861d44a2e3a5036ab66648c28073ccea088899b68be6af3
MD5 6061fb06b57816e7012634c1d864baf8
BLAKE2b-256 4cbc1cfc37ad7232d7dee948e139ac830e27c30eb2a1cb7877b8b16c1c3a8665

See more details on using hashes here.

Provenance

File details

Details for the file flake8-import-order-0.6.linux-x86_64.tar.gz.

File metadata

File hashes

Hashes for flake8-import-order-0.6.linux-x86_64.tar.gz
Algorithm Hash digest
SHA256 9bc55fa8840a80793a5e6733003e29f5e6b6fe812a4d5ccbbabf02bedee4c17e
MD5 3052f6a6f802a8c556e7c0f56d0668df
BLAKE2b-256 6cee524f5fc0cc96387b78daa84afd514ee0e7813a6f500e81eeeb5c89768d27

See more details on using hashes here.

Provenance

File details

Details for the file flake8_import_order-0.6-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_import_order-0.6-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 b4a58e697dff563bdcb5feff40b2836b631e1ecac7fc104e3a0a0fce8fdda9b1
MD5 a8d6ff8600a6c6a7575c02a553c00b72
BLAKE2b-256 bea33921d589e06aab2c9eb236f035e1154a4274897c53d35e8a8113981e2aa7

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page