pyflakes
https://pypi.python.org/pypi/pyflakes is like pylint, but 10 times faster. This creates a new opportunity: Leo should have an option to run pyflakes on all dirty @file nodes when saving a .leo file.
pyflakes is a breath of fresh air. The code is much simpler than its fantastically complex "competitors", including my stc project! I have found it easy to change the pyflakes code.
Yesterday I wrote a Leo script to drive pyflakes on Leo files. As of rev 341, this script is in the stc project in the node "@test *local* pyflakes". This node contains a repacking of all the classes in pyflakes. I will soon cut and paste this node into scripts.leo.
I used this script to remove all the "flakes" from Leo's core files. This revealed two true bugs in Leo. I found only one bug in pyflakes--pyflakes generates an erroneous flake for::
dn = self.def_stack[-1]
dn.code += s
pyflakes says that dn isn't used after being defined! Happily, no flake appears for::
self.def_stack[-1].code += s
It will be easy to integrate pyflakes into Leo (see below), but I want to investigate pyflakes in
more detail first...
Edward
P.S. I made the following changes to a local copy of pyflakes in the stc project:
Repackaged all the pyflakes classes so they could be used by the Leo script. This was remarkably easy to do.
The Reporter class now funnels all its output to the new r.write method. This method does nothing if the output stream is None. This allows timing runs that ignore the time taken to print flakes. For Leo, r.write might create a gui table that will take you to the proper place in the source code if you click one of the rows. Iirc, Kent has asked for something like this when Leo reports syntax errors in the code.
Changed runFunction (a helper function in the Checker class) so that pyflakes doesn't complain about unused vars for vars whose names start with 'unused' or 'junk'.
Changed Message.__repr__ so that it uses short file names when the global ekr switch is true. This makes flakes much easier to read. The Leo driver script reports enough context so that these shorter flakes suffice.
Rev 341 also contains the "@test pyflakes unit tests" driver that runs all the pyflakes unit tests on (possibly modified) code in python/Lib/site-packages. Many unit tests depend on Message.__repr__: they will fail if ekr is True. As I write this, I see that the solution will be to add a new argument to the Message ctor. m.__repr__ can use this arg to determine whether it is being called in a unit test.
EKR