Flake8: import statements are in the wrong order

PEP8 suggests that:

Imports should be grouped in the following order:

1. standard library imports
2. related third party imports
3. local application/library specific imports

You should put a blank line between each group of imports.

I am using Flake8Lint , which is a Sublime Text plugin for Python Lint files.

My code is as below:

import logging
import re
import time
import urllib
import urlparse

from flask import Blueprint
from flask import redirect
from flask import request
from flask.ext.login import current_user
from flask.ext.login import login_required

from my_application import one_module

it will show a warning as below:

Import statements

are in the wrong order, from my_application should be up from from flask.ext.login.

but the checkbox is a third-party library, it should be before my import my_application. That's why? How to fix it?

+4
source share
1 answer

The flake8-import-order plugin must be configured to find out which names should be considered local to your application.

.flake8 ini :

[flake8]
application_import_names = my_application

:

from __future__ import absolute_import

import os
import sys

import requests

from . import (
    client
)


...
+1

Source: https://habr.com/ru/post/1656050/


All Articles