logilab-astng #5010 pb w/ py2.5 absolute import [resolved]
Here is a simplified example that exhibits the problem.
Parent is the parent package to sub-packages A and B.
Sub-Package A: Parent/A/__init__.py contains "import a" Parent/A/a.py contains:
from __future__ import absolute_import from ..B import b class aClass(b.bClass): def __init__(self): b.bClass.__init__(self) def foo(self): print self.x print self.y print self.z
Sub-Package B: Parent/B/__init__.py contains "import b" Parent/B/b.py contains:
class bClass: def __init__(self): self.x = 0 self.y =  self.z = ''
The Parent package is located in my sys.path. The above code runs just fine:
>>> import Parent.A >>> a = Parent.A.a.aClass(1) >>> a.foo() 0
However, when I run pylint for A/a.py it gives me
F0401: 9: Unable to import 'B.b' (No module named B)
and therefore of course the ensuing errors:
E1101: 14:aClass.foo: Instance of 'aClass' has no 'x' member E1101: 15:aClass.foo: Instance of 'aClass' has no 'y' member E1101: 16:aClass.foo: Instance of 'aClass' has no 'z' member
If I change the import syntax in Parent/A/a.py to use "from Parent.B import b" all errors go away. This seems to indicate a problem with intra-sub-package relative imports.
|appeared in||<not specified>|
|closed by||<not specified>|