pylint icon indicating copy to clipboard operation
pylint copied to clipboard

Relative imports don't work if processed after empty package

Open marcinbarczynski opened this issue 8 years ago • 0 comments

Steps to reproduce

  1. 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
  1. All __init__.py files are empty.
  2. Contents of ./b/src/test/test.py:
from .foo import bar

bar()
  1. 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]

marcinbarczynski avatar Apr 18 '17 09:04 marcinbarczynski