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

Fix ambiguous I100 message #98

Closed peterjc closed 7 years ago

peterjc commented 7 years ago

Sometimes the I100 message has the unhelpful form "from X should be before from X"

Simple test case based on a real example:

$ more tests/test_cases/wrong_from_import_same.py
from os import system
from os import path # I100

Before the fix would get this:

$ flake8 --select I100 tests/test_cases/wrong_from_import_same.py
tests/test_cases/wrong_from_import_same.py:3:1: I100 Import statements are in the wrong order. from os should be before from os

With this change you get this:

$ flake8 --select I100 tests/test_cases/wrong_from_import_same.py
tests/test_cases/wrong_from_import_same.py:3:1: I100 Import statements are in the wrong order. path should be before system
peterjc commented 7 years ago

Note it was not obvious to me if and how you check the exact wording of the error messages, which is why I've not implemented that.

pgjones commented 7 years ago

Looks good to me as well, thanks.