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
typingmodule. 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:
normal_names, and follow that order:
from something import CONST_A, CONST_B, ClassA, ClassB, any_func, any_var
[flake8] import-order-style = spoqa
To be released.
Initial release. Released February 12, 2017.