[Python-projects] pylint: E1101: Instance of 'None' has no 'xyz' member
Alexandre Fayolle
alexandre.fayolle at logilab.fr
Mon Apr 14 10:57:46 CEST 2008
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 ?
--
Alexandre Fayolle LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations
Développement logiciel sur mesure: http://www.logilab.fr/services
Informatique scientifique: http://www.logilab.fr/science
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: Digital signature
Url : http://lists.logilab.org/pipermail/python-projects/attachments/20080414/e76a9991/attachment.pgp
More information about the Python-Projects
mailing list