You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Barry Warsaw f65c3d9f04
Fix the issue number
4 years ago
flufl/flake8 Fix support for relative (i.e. dotted) imports. Closes #31 4 years ago
.gitignore First commit after package split 5 years ago
LICENSE.txt First commit after package split 5 years ago
MANIFEST.in First commit after package split 5 years ago
NEWS.rst Fix the issue number 4 years ago
README.rst First commit after package split 5 years ago
setup.py setuptools.find_package() can't find namespace package 5 years ago
setup_helpers.py First commit after package split 5 years ago

README.rst

flufl.flake8

This is a plugin for flake8 which checks for my particular import style. It was previously part of flufl.testing but as nose2 becomes much less popular than pytest, it makes more sense to provide the flake8 plugin as a separate package.

Python 3.4 is the minimum supported version.

flake8 import order plugin

This flake8 plugin enables import order checks as are used in the GNU Mailman project. Specifically, it enforces the following rules:

  • Non-from imports must precede from-imports.
  • Exactly one line must separate the block of non-from imports from the block of from imports.
  • Import exactly one module per non-from import line.
  • Lines in the non-from import block are sorted by length first, then alphabetically. Dotted imports count toward both restrictions.
  • Lines in the from import block are sorted alphabetically.
  • Multiple names can be imported in a from import line, but those names must be sorted alphabetically.
  • Names imported from the same module in a from import must appear in the same import statement.

It's so much easier to see an example:

import copy
import socket
import logging
import smtplib

from mailman import public
from mailman.config import config
from mailman.interfaces.mta import IMailTransportAgentDelivery
from mailman.mta.connection import Connection
from zope.interface import implementer

To enable this plugin1, add the following to your tox.ini or any other flake8 recognized configuration file:

[testenv]
deps = flufl.flake8

[flake8]
enable-extensions = U4

Author

flufl.flake8 is Copyright (C) 2013-2018 Barry Warsaw <barry@python.org>

Licensed under the terms of the Apache License, Version 2.0.

Project details

Footnotes


  1. Note that flake8 3.1 or newer is required.