PyCQA / flake8-import-order

Flake8 plugin that checks import order against various Python Style Guides
GNU Lesser General Public License v3.0
278 stars 72 forks source link

Allow styles an ability to override the actual checks #131

Closed pgjones closed 6 years ago

pgjones commented 6 years ago

This is specifically helpful to allow the edited style to have an optional newline between import and form X import lines without triggering a I202 error.

In a more general sense this should allow for more advanced styles.

pkatseas commented 6 years ago

This looks really good @pgjones, thanks for taking the time to look into it!

I'm afraid there's still one example that's not covered under this implementation:

from a_repo import settings

from .exceptions import AnError
from .a_module import MyClass
from ..base import BaseClass

The empty line between the imports is still causing an I202, even though the following entry is in our setup.cfg and from a_repo imports should(?) be considered to be in the same group as relative (from .) imports:

[flake8]
application-import-names = a_repo

Edit: I'm more than happy to fix this myself if you don't mind an extra PR by the way.

pgjones commented 6 years ago

@pkatseas I think this then represents the actual edited style, can you take a look at the complete example and note if any of it is not the edited style?

pgjones commented 6 years ago

@pkatseas Is this style correct now?

janrito commented 6 years ago

This is brilliant, thanks @pgjones. It works as expected