[Python-projects] pylint: W0706

Sylvain Thénault sylvain.thenault at logilab.fr
Wed Jul 30 15:16:13 CEST 2008


On Wed, Jul 30, 2008 at 03:08:13PM +0200, Maarten ter Huurne wrote:
> syt at logilab.fr wrote on 2008-07-30 02:50:00 PM:
> 
> > On Wed, Jul 30, 2008 at 02:27:15PM +0200, Maarten ter Huurne wrote:
> > > ===
> > > W0706: 11: Identifier MultiException().add_error('blah') used to raise
> an
> > > exception is assigned to class MultiException(Exception):
> > >     def __init__(self):
> > >         Exception.__init__(self)
> > >         self.messages = []
> > >     def add_error(self, message):
> > >         self.messages.append(message)
> > >         return self
> > >  line 1
> > > ===
> > >
> > > I don't understand what this warning is warning me about.
> >
> > huum, I think pylint is trying to check that the exception you're
> > raising is something that can actually be raised, but in that case an
> > inference pb caused the false positive.
> 
> Thanks for the explanation.
> 
> That seems to be the case indeed: "raise 1 + 1" causes a similar warning:
>   W0706: 12: Identifier (1) + (1) used to raise an exception is assigned to
> 2 line 12
> 
> The wording is a bit confusing, I would expect something like 'Expression
> "(1) + (1)" has type "int" but is raised as an exception'.

I've added this to the ticket: http://www.logilab.org/ticket/5672 

> It seems though that the inference correctly determined that
> MultiException.add_error() returns a MultiException object, since the
> warning was able to print the body of the MultiException class.

true. That may be easier to fix after all ;)

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