Next step after pychecker
Steven Bethard
steven.bethard at gmail.com
Tue Feb 1 00:15:38 EST 2005
Philippe Fremy wrote:
> I would like to develop a tool that goes one step further than pychecker
> to ensure python program validity. The idea would be to get close to
> what people get on ocaml: a static verification of all types of the
> program, without any kind of variable declaration. This would definitely
> brings a lot of power to python.
It's a very cool idea, and there was talk of including such a tool in
Python 3.0, though as yet, no one has volunteered to solve this problem.
=) Note that you can't actually really ensure program validity, but you
can make some educated guesses like pychecker does. An example:
def f1(a):
return a + 1
def f2():
return f1([])
Your suggestion was that this code should be deemed invalid. But if
it's followed with:
f1 = ''.join
f2()
where f1 is rebound, then it's perfectly valid code. That said, I think
providing "suggestions" like pychecker does is definitely worth pursuing.
> What is in your opinion the best tool to achieve this ? I had an
> extensive look at pychecker, and it could certainly be extended to do
> the job. Things that still concern me are that it works on the bytecode,
> which prevents it from working with jython and the new .NET python.
I don't know much about what pychecker does, but if it works with the
bytecode, shouldn't it be fine for jython and IronPython? I thought the
bytecode was part of the language spec, and what was CPython specific
was how the bytecodes were actually implemented...
> I am currently reading the documentation on AST and visitor, but I am
> not sure that this will be the best tool either. The AST seems quite
> deep and I am afraid that it will make the analysis quite slow and
> complicated.
You should read up on the recent python-dev discussions about merging
the AST branch. I don't know too much about it, but apparently there's
some work being done currently on how the AST is used in Python. Sorry
I don't know more about this...
Steve
More information about the Python-list
mailing list