pyflakes now warns about unused local variables
I finally got around to finishing my fix for Divmod bug #2718 -- Warn about unused variables in methods in pyflakes. Last night, the magnificent Jean-Paul Calderone reviewed and landed my patch. This means that if you are using pyflakes trunk (either from Subversion trunk or from the Launchpad Bazaar import), pyflakes will spot code like:
def foo(bar):and generate a warning like:
baz = bar + 2
return 12
example.py:2: local variable 'baz' is assigned to but never usedI use pyflakes hooked up to flymake, so it's always running all the time on every Python file I'm working on. Relying on it has become as second-nature as relying on syntax highlighting. There's a whole class of mistakes I don't make any more, simply because it's on.
However, the main way it helps me is when I'm refactoring code. When extracting a function or changing a variable name, pyflakes acts like a sort of todo list for me. Now that it shows unused local variables, it's getting dangerously close to perfect.
To get pyflakes quickly, bzr branch lp:pyflakes.
(Edit: Grammar fix)

2 Comments:
Thanks -- I use pyflakes with flymake too, and it is a godsend!
Nice one! I've packaged trunk in my PPA
Post a Comment
<< Home