In reference to How do I import a Python script from a sibling directory?, Pylint will error with E0401
:Unable to import at line 6.
if __name__ == '__main__':
if __package__ is None:
import sys
from os import path
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))
from components.core import my_module
else:
from ..components.core import my_module
Is this just something that we have to accept, or is there a rigorous solution to correct this?
While the file in question is part of my unit tests and not critical to deployment, I would like to keep everything error free.
(pylint 1.6.4, Python 2.7.12)