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.3.0

Released on February 12, 2018.

  • Older versions than flake8-import-order 0.17 are now unsupported. (Under the hood, since flake8-import-order 0.17 refactored their internals so that constants like IMPORT_3RD_PARTY, IMPORT_APP, IMPORT_APP_PACKAGE, IMPORT_APP_RELATIVE, and IMPORT_STDLIB are evolved to ImportType enum type, flake8-import-order-spoqa also became to follow that.) [#3]

Version 1.2.0

Released on November 27, 2017.

  • Older versions than flake8-import-order 0.16 are now unsupported. (Under the hood, since flake8-import-order 0.16 refactored their internals so that no more Style.check() method and Style.imports property exist, flake8-import-order-spoqa also became to follow that.)

Version 1.1.0

Released on October 31, 2017.

  • Older versions than flake8-import-order 0.14.2 are now unsupported.

Version 1.0.2

Released on October 31, 2017.

  • Fixed incompatibility with flake8-import-order 0.14.1 or higher.

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.3.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

flake8_import_order_spoqa-1.3.0-py2.py3-none-any.whl (7.8 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for flake8-import-order-spoqa-1.3.0.tar.gz
Algorithm Hash digest
SHA256 bee910371352aca1a28b078b29ba7f1610d10fbccec98a8c3cc98003e133439c
MD5 78044704c4669ea4c875712e69852cac
BLAKE2b-256 4e78d33e89d847985bfe27caa1b7437bf2d379fb86e829f72987178cea04ee08

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flake8_import_order_spoqa-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c5c6d0a1f35753de109c49ec914918b5094b471c3120767e502d076aace6ac40
MD5 bae41798b79e05745e7b2e3969d77b81
BLAKE2b-256 f337878486dcf41b24bf52f85b03cb36caf3cb4b1080ec69352c1c25301bcfeb

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