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

Duncan Gibson duncan at thermal.esa.int
Mon Apr 14 11:25:55 CEST 2008


I 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?

Alexandre replied:
> 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.

Yes, findThing() can return None, so the test is already there.
I am very happy that pylint reports the problem when I forget to
add the test, but it is a little inconvenient that pylint still
reports a problem even when the test is there. This pattern occurs
very frequently in the code, so there are always spurious warnings
so a real problem report could easily be missed.

In the other reply, Sylvain said that no versions of pylint/astng
currently handle this problem, but it would be a useful feature, so
could I make this a request for future enchancement?

Cheers
Duncan


More information about the Python-Projects mailing list