] > Re: [Python-projects] pylint: Confused by failed import (Logilab.org)

Email Re: [Python-projects] pylint: Confused by failed import

from
cc
subject
Re: [Python-projects] pylint: Confused by failed import
date
2006/03/09 18:36
On Thursday 09 March à 18:17, Maarten ter Huurne wrote:
> syt@logilab.fr wrote on 2006-03-08 03:48:08 PM:

> > On Monday 06 March ? 19:40, Maarten ter Huurne wrote:
> > > Hi,
> > > 
> > > If I feed pylint the following modules, it reports an error I would 
> not 
> > > expect:
> > > 
> > > === super.py:
> > > import this_module_does_not_exist
> > > 
> > > class Super(object):
> > >     def inherited_method(self):
> > >         pass
> > > === sub.py:
> > > from super import Super
> > > 
> > > class Sub(Super):
> > >     def some_method(self):
> > >         self.inherited_method()
> > > ===
> > > 
> > > On "sub.py", pylint reports this error:
> > > ===
> > > E:  5:Sub.writeContent: Instance of 'Sub' has no 'inherited_method' 
> member
> > > ===
> > > 
> > > This problem disappears if I remove the import of the non-existing 
> module. 
> > > So it seems a failed import somehow confuses pylint.
> > 
> > hum, yes... To get correct inference results, it needs to correctly get
> > parent classes (at least). I'm not sure it will be possible to fix this 
> > problem (more exactly, is it worth spending necessary time on it...). An 

> > alternative would be to deactivate the "typecheck" checker when all 
> > dependencies 
> > are not available.

> I don't really understand this problem...

> There is no missing information in the module that could not be imported: 
> if this import is removed, everything is fine. So it seems that pylint is 
> not using any definitions from "super.py" because of the failed import. If 
> it would just report and then ignore the failed import, it should be able 
> to avoid issuing the error. Or am I overlooking something?

As I understand it, the problem is that the "inherited_method" is
defined in super.py so when pylint try to guess where the
"inherited_method" is coming from when it's called in a Sub method, it just
fails if it doesn't find the super module and so report a missing
attribute problem. 

-- 
Sylvain Thénault                               LOGILAB, Paris (France).

http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org


is a reply to
has reply