skip to navigation
skip to content

flake8-import-order-spoqa 1.0.1

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

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.

 
File Type Py Version Uploaded on Size
flake8-import-order-spoqa-1.0.1.tar.gz (md5, pgp) Source 2017-07-15 4KB
flake8_import_order_spoqa-1.0.1-py2.py3-none-any.whl (md5, pgp) Python Wheel 3.6 2017-07-15 6KB