pylint #5672 W0706 weirdness [resolved]
maarten reported... When I run pylint on the following code: class MultiException(Exception): def __init__(self): Exception.__init__(self) self.messages = [] def add_error(self, message): self.messages.append(message) return self raise MultiException().add_error('blah') I get the following output: 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 I don't understand what this warning is warning me about. Also, I think it's very strange that the class body is included in the warning. Versions used: pylint 0.14.0, astng 0.17.2, common 0.22.1 Python 2.5.1 (r251:54863, Mar 7 2008, 03:41:45) | |
priority | normal |
---|---|
type | bug |
done in | 0.15.2 |
load | 0.000 |
load left | 0.000 |
closed by | <not specified> |
Comments
-
2008/07/30 13:07, written by sthenault
-
2008/09/24 15:22, written by eanclin
add commentThe 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.
this happens also on this case
yielding
but no warning for
(where there should be at least a warning since python raises TypeError )