[Python-projects] pylint: W0706
Maarten ter Huurne
maarten.ter.huurne at philips.com
Wed Jul 30 15:08:13 CEST 2008
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'.
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.
Bye,
Maarten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.logilab.org/pipermail/python-projects/attachments/20080730/1eadae9d/attachment.htm
More information about the Python-Projects
mailing list