import_order.py file: """
This module should not give pylint errors
"""
import mock
import unittest
def test():
"""
To suppres pylint
"""
mock.Mock()
_ = unittest
> pylint import_order.py
************* Module test_pylint
C: 6, 0: standard import "import unittest" comes before "import mock" (wrong-import-order)
Error message says C: 6, 0: standard import "import unittest" comes before "import mock" (wrong-import-order)
Error message should say
C: 6, 0: standard import "import unittest" comes after "import mock" (wrong-import-order)
Or
C: 6, 0: "import mock" comes before standard import "import unittest" (wrong-import-order)
pylint --version
pylint 1.6.5,
astroid 1.4.9
Python 2.7.12 (default, Jul 29 2016, 11:13:37)
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)]
Why you assume that errors shouldn't be triggered? IIRC, isort groups imports as in:
mock belongs to second tier, unittest to first.
@rogalski If nothing else, the error message is wrong. it should be:
C: 6, 0: "import mock" comes before standard import "import unittest" (wrong-import-order)
@rogalski yes, your're right, mock should actually go after unittest. So error is being triggered correctly.
But the error message is wrong and confusing.
So I've updated issue title and expected behavior section with message suggested by @degustaf and another option.
Most helpful comment
@rogalski If nothing else, the error message is wrong. it should be:
C: 6, 0: "import mock" comes before standard import "import unittest" (wrong-import-order)