[Python-projects] pylint: E1101: Instance of 'None' has no 'xyz' member

Sylvain Thénault sylvain.thenault at logilab.fr
Mon Apr 14 10:59:09 CEST 2008


On Mon, Apr 14, 2008 at 10:57:46AM +0200, Alexandre Fayolle wrote:
> On Mon, Apr 14, 2008 at 10:51:06AM +0200, Duncan Gibson wrote:
> > 
> > There are various places in my code where I have something like:
> > 
> >     thing = findThing()
> >     if thing is not None:
> >         thing.doIt()
> > 
> > but pylint reports E1101: Instance of 'None' has no 'doIt' member.
> > 
> > Apart from adding # pylint: disable-msg=E1101 comments everywhere
> > in the code, is there some way of restructuring the code to avoid
> > the [unnecessary?] warning?
> > 
> > If not, would it be possible to enhance pylint to recognise that
> > the access to thing.doIt is protected by a test that thing exists?
> 
> First question that comes to my mind: can the call to findThing return
> None? If not, then do not add a test just to please pylint. That's the
> wrong approach. 
> 
> That said, which version of Pylint are you using ? 

no version of pylint/astng are supporting this :(

-- 
Sylvain Thénault                               LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
Python et calcul scientifique:           http://www.logilab.fr/science



More information about the Python-Projects mailing list