Skip to main content

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

Project description

Build Status

A flake8 and 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. 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

  • google - style described in Google Style Guidelines, see an example

  • smarkets - style as google only with import statements before from X import … statements, see an example

  • pep8 - style that only enforces groups without enforcing the order within the groups

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.

I201 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 Distribution

flake8-import-order-0.8.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

flake8_import_order-0.8-py2.py3-none-any.whl (11.5 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for flake8-import-order-0.8.tar.gz
Algorithm Hash digest
SHA256 e9ceee1afd1144bff11cc4d23e6c630f9311f34c13912cf3f3a08ae90bb0d937
MD5 caf8cd50441b1afc894241bf15128aff
BLAKE2b-256 182f5efcf6f5dc074334b5d02627bf58bf8cefaf63e68ba5fbae51cb8cf34110

See more details on using hashes here.

Provenance

File details

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

File metadata

File hashes

Hashes for flake8_import_order-0.8-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 fd26e9a0f9a58708f1e8b35c537ef9a2a2a8e56eff0fccfbf4466a7fb5344e08
MD5 badb1e48080e99d7a3f44d1f5820131f
BLAKE2b-256 3ee4d1613f6ba0cf5325a02a94dd36cc8276541e745f966334e8fda80f62ec4a

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