Skip to main content

Grok Learning's flake8-import-order plugin.

Project description

flake8-import-order-grok

A flake8-import-order ordering definition, defining Grok Learning's preferred import order style.

The import order enforced by this style is:

  1. __future__
  2. builtins
  3. Django
  4. Non-django third-party, grouped by package
  5. Application packages

All groups of imports require a line break between them, except between __future__ and builtins.

All imports must be alphabetical horizontally and vertically. Within an import unit, names must be constants first, followed by classes, followed by functions (i.e. CAPITAL_CASE, CamelCase, underscore_case).

The names of the application packages can be configured via the application-import-names setting in flake8.

For example, if application-import-names is set to my_project, this import ordering enforces the following ordering:

# coding: utf-8
from __future__ import absolute_import, print_function, unicode_literals  # 1. `__future__`
import io  # 2. Builtins.
import logging
import os
import tarfile

from django.conf import settings  # 3. Django.
from django.utils.http import urlencode

from dns.exception import DNSException, Timeout  # 4. Non-Django third-party packages, each one separated by a blank line.
from dns.resolver import NXDOMAIN, NoAnswer, Resolver

import requests

import ujson

from my_project.core.enums import Enum  # 5. Application packages.
from my_project.utils.download import DOWNLOAD_TIMEOUT, InvalidURLException, download_content_url

Usage

Install the flake8-import-order-grok package using pip, then tell flake8 to use this import order style using the --import-order-style=grok command-line option, or by setting it in setup.cfg. The names of your application package(s) can be set by the application-import-names setting:

[flake8]
import-order-style = grok
application-import-names = my_package1, my_package2

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-grok-0.3.1.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

flake8_import_order_grok-0.3.1-py2.py3-none-any.whl (5.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file flake8-import-order-grok-0.3.1.tar.gz.

File metadata

  • Download URL: flake8-import-order-grok-0.3.1.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for flake8-import-order-grok-0.3.1.tar.gz
Algorithm Hash digest
SHA256 b8fcbef0f22f194b5f5ce1308e064886912e8112b64392bbdbfe83af25d40e5c
MD5 1b03d590df731eea60367a60eb69f92d
BLAKE2b-256 a734efb4b8f37e110e13a1bdb3260f54449f31757155179a0529ef6efbbfdff6

See more details on using hashes here.

File details

Details for the file flake8_import_order_grok-0.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: flake8_import_order_grok-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for flake8_import_order_grok-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4dd0a4f1c3f2fdf839cb13dd607fdfd2c75dae7f6e483e6a03f540a9326c2208
MD5 e784d292e5c22f47117e2f23adf8b4a3
BLAKE2b-256 457cd19d8b476ff04d64b95c66f0e9b42b772d24f8cfeaae70d79257f02ee251

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