PyChecker - a python source code bug finder
Neal Norwitz
neal at metaslash.com
Fri Apr 13 15:25:20 EDT 2001
Robin Becker wrote:
> class B:
> def __init__(self):
> self.x=1
> class A(B):
> member = 1
>
> C:\Python\pyChecker>python checker.py a.py
>
> b.py:0 No __init__() in subclass (A)
Yes, this was by design. Although the error should be in a.py, not b.py.
That's been fixed in CVS.
In addition, I have made this warning configurable. The code is fine,
it is completely legal to inherit __init__ and not override. The idea
was that it it is often a mistake to not override.
But this is not always a good assumption....so....
-I, --initsubclass Subclass.__init__() not defined [on]
That's a new command line option in CVS version.
There are many cases where you want to write completely legal code,
but checker can't tell if it is a bug (thinko mistake) or what was intended.
Ideally, there would be finer grain control on the options.
So one could specify for a particular class/method, set option X to some value.
In 2.1, this could be done with function attributes. But I don't know how to
deal with these cases for modules/classes/functions generically.
One option would be to review the actual doc strings and look for hints
(similar to lint /*ARGSUSED*/). Perhaps "CHECKER.initsubclass = 1" ?
Any ideas or comments?
Neal
More information about the Python-list
mailing list