[Python-Dev] whitespace normalization pre-commit hook is giving me grief
g.brandl at gmx.net
Tue May 29 09:33:05 CEST 2007
Scott Dial schrieb:
> Martin v. Löwis wrote:
>> Brett Cannon schrieb:
>>> Unfortunately the pre-commit hook
>>> does not specify what line a change was made on so I have no clue where
>>> it is failing (maybe this should be added?).
>> It creates a reindent.Reindenter on the new contents, then invokes
>> .run() on it, and complains if that returns true. If you can come
>> up with a patch to reindent that makes it report more detailed
>> errors, please post it, and I'll try to merge it into the hook
> How about you do:
> if reindenter.run():
> print >>sys.stderr, "file %s is not whitespace-normalized" %path
> print >>sys.stderr, difflib.unified_diff(reindenter.raw,
> bad += 1
> Which would provide you a unified diff to give you a clue.
As I said before, you don't really need that when you can (and should!) just run
reindent.py over the source file yourself, not care about any diffs and just
In this particular case, the diff wouldn't have helped too, since there was no
way to "fix" the SVN-generated file content...
Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.
More information about the Python-Dev