Skip to main content

Spoqa's import order style for flake8-import-order

Project description

https://img.shields.io/pypi/v/flake8-import-order-spoqa.svg https://travis-ci.org/spoqa/flake8-import-order-spoqa.svg

This extends flake8-import-order to implement Spoqa’s import order convention. It bascially follows PEP 8 with our some additional rules:

  • Standard libraries shouldn’t be imported using from ... import ... statement. It’s because standard libraries tend to use general terms like open. We instead use always qualified imports to eliminate name pollution:

    import sys  # Yes
    
    from sys import version_info  # No

    However, there are few exceptions like typing module. They can be imported in both ways:

    import typing
    from typing import Optional  # `from ... import ...` must be latter
  • All other than standard libraries should be imported using from ... import ... statement:

    from flask import Flask  # Yes
    
    import flask  # No
  • Deeper relative imports should go former. This rule makes consistent even when relative imports are rewritten as absolute imports.

    from ..deeper import former
    from ...deepest import later
  • Imported names are splited to three categories: CONSTANT_NAME, ClassName, and normal_names, and follow that order:

    from something import CONST_A, CONST_B, ClassA, ClassB, any_func, any_var

Usage

Install the flake8-import-order-spoqa using pip, and then specify --import-order-style=spoqa option. Or you can specify it on the config file as well:

[flake8]
import-order-style = spoqa

Because runtime extensible styles is introduced from flake-import-order 0.12, you need to install flake-import-order 0.12 or later.

Distribution

Written by Hong Minhee, and distributed under GPLv3 or later.

Changelog

Version 1.0.1

Released on July 15, 2017.

  • Fixed a bug that wrong order of names (e.g. from ... import second, first) had been not warned.

Version 1.0.0

Initial release. Released on February 12, 2017.

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-spoqa-1.0.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

flake8_import_order_spoqa-1.0.1-py2.py3-none-any.whl (6.9 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file flake8-import-order-spoqa-1.0.1.tar.gz.

File metadata

File hashes

Hashes for flake8-import-order-spoqa-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b8e690839d064c74a412c7be0b4ea338b1cd2029941fb0622beec5ae5d398b0d
MD5 28cb69307f870af6aed1ae5696740448
BLAKE2b-256 07ed6d2c3cdf25d2c8f8b77cf457dfb98e91c99ede6100177a87e27c591b7bd1

See more details on using hashes here.

File details

Details for the file flake8_import_order_spoqa-1.0.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for flake8_import_order_spoqa-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4bbec51c022468c2f49d08ef3ae486cfbd3fbb3e67513f690014fac2a5a119cb
MD5 10d60831a69d41e83adbf535122be41b
BLAKE2b-256 ff5f599126883a1da7401402b753e73a8eee1fea588e2d9c07f749f123e80df9

See more details on using hashes here.

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