pylint #8878 fails on a relative import [resolved]

**** module storage.formats.swap
F: 26: Unable to import 'devicelibs' (No module named devicelibs)

The import line in question is:

"from ..devicelibs import swap"

Note that we have the following dir hierarchy:

storage
storage/__init__.py
storage/errors.py
storage/<other>.py
storage/devicelibs/__init__.py
storage/devicelibs/<other>.py
storage/formats/__init__.py
storage/formats/<other>.py

Right above the failing import from devicelibs, we have:

"from ..errors import *"

pylint does sucessfully handle this, but the relative import of the devicelibs (sub)package seems to confuse it.

To get the anaconda sourcecode do the following:

git clone http://git.fedorahosted.org/git/anaconda.git
<go get some coffee, it contains years of history>
cd anaconda

If you want to reproduce the problem, you may need to take a few other steps to be able to run pylint successfully on the storage package:

  1. You will need to make the native isys module:

    cd isys
    make
    
  2. You will need to install pyparted:

    https://fedorahosted.org/releases/p/y/pyparted/
    
  3. You will need to install pyblock:

    git clone http://git.fedorahosted.org/git/pyblock.git
    
  4. You will need to run pylint as root, as pyparted refuses to be imported as normal user (or patch pyparted to not do this check, which we need to remove anyways).

Here is how I run pylint:

sudo pylint --init-hook='import sys; sys.path.insert(1, "isys")' --disable-msg-cat=CRW -r n storage
priorityimportant
typebug
done in0.18.1
load0.500
load left0.000
closed by<not specified>