Skip to main content

ruler501's flake8-import-order plugin.

Project description

flake8-import-order-ruler501

A flake8-import-order ordering definition, defining ruler501's preferred import order style. Originally based on flake8-import-order-grok

The import order enforced by this style is:

  1. __future__
  2. builtins
  3. third-party, grouped separately by package
  4. Application packages by package
  5. Relative imports

All groups of imports require a line break between them, except packages within your application.

All imports must be alphabetical horizontally and vertically. from import groups are on separate lines sorted by 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.1 django
from django.utils.http import urlencode

from dns.exception import DNSException, Timeout  # 3.2
from dns.resolver import NXDOMAIN
from dns.resolver import NoAnswer, Resolver

import requests # 3.3 

import ujson #3.4

from my_project.views import MainView  # 4. Application packages.
from my_project.core.enums import Enum
from my_project.utils.download import DOWNLOAD_TIMEOUT
from my_project.utils.download import InvalidURLException
from my_project.utils.download import download_content_url

from .models import Article

Usage

Install the flake8-import-order-ruler501 package using pip, then tell flake8 to use this import order style using the --import-order-style=ruler501 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 = ruler501
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-ruler501-0.18.1.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

flake8_import_order_ruler501-0.18.1.1-py2.py3-none-any.whl (5.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file flake8-import-order-ruler501-0.18.1.1.tar.gz.

File metadata

  • Download URL: flake8-import-order-ruler501-0.18.1.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.6

File hashes

Hashes for flake8-import-order-ruler501-0.18.1.1.tar.gz
Algorithm Hash digest
SHA256 05f437dfbd54b34e7f4c3050ad334e91a96e797257daa206d3e30954b207ee73
MD5 dad00f070a60de429a294cadcc31e05c
BLAKE2b-256 934f373380bab6cf16733675e4dd6c990e376a250a35847f823c532cab40445e

See more details on using hashes here.

File details

Details for the file flake8_import_order_ruler501-0.18.1.1-py2.py3-none-any.whl.

File metadata

  • Download URL: flake8_import_order_ruler501-0.18.1.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.18.4 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.34.0 CPython/3.6.6

File hashes

Hashes for flake8_import_order_ruler501-0.18.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4f718a2d23798b1e7bab2cc6e1897d30a1c17e1ac49a39753357df3c6d255764
MD5 f1fc4b50f86100840a363f5e72acc8ed
BLAKE2b-256 7eaf618aa9b8430bee9f406075c61bf0f4683373af4fcb9ed3f548b77f013b8c

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