pylint
pylint copied to clipboard
Relative imports don't work if processed after empty package
Steps to reproduce
- Create the following directory tree:
./a
./a/src
./a/src/__init__.py
./b
./b/src
./b/src/__init__.py
./b/src/test
./b/src/test/foo.py
./b/src/test/test.py
./b/src/test/__init__.py
- All
__init__.pyfiles are empty. - Contents of
./b/src/test/test.py:
from .foo import bar
bar()
- Contents of
./b/src/test/foo.py:
def bar():
print "bar"
Current behavior
$ pylint -E -j 2 a/src b/src/test/test.py
************* Module src.test.test
E: 1, 0: Unable to import 'src.test.foo' (import-error)
$ pylint -E -j 2 b/src/test/test.py a/src # reversed order
# no errors
$ pylint -E -j 2 b/src/test/test.py
# no errors
I get the same error without -j 2 as well.
Expected behavior
pylint -E -j 2 a/src b/src/test/test.py should print no errors the same as pylint -E -j 2 b/src/test/test.py a/src
pylint --version output
pylint 1.6.5,
astroid 1.4.9
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2]