On line 12, why do you strip and split p.stdout exactly? (I notice when reverting this, the precommit hooks fails.)
Because run is first called with a 'git diff-index' and in that case the p.stdout.read().strip().split() is a list of filenames. Of course you're right, in the pyflakes case the strip() and split() on the output is unnecessary. This would probably be easier to understand if there was a separate function for getting the list of modified file names.
Ah- Somehow I had completely missed line 14. Much easier to understand the control-flow now.
Helpful modification I've been using:
L14 should probably be
_, files_modified, _= run("git diff-index --name-only --cached HEAD")
so that non-staged files are ignored. i.e. we only run pyflakes against the files we're trying to commit, not the entire source tree.
Thanks @mtigas, I've updated the gist.