from
Maarten ter Huurne <maarten.ter.huurne at philips dot com>
to
Sylvain Thénault <sylvain.thenault at logilab dot fr>
cc
Python-Projects <python-projects at lists dot logilab dot org>
subject
Re: [Python-projects] pylint: Confused by failed import
date
2006/03/09 18:17
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?
Bye,
Maarten
