Some time ago I looked for something similar and found Pyflakes, which uses Python's compiler module to do some simple checks. This looks more promising. I have patched Pyflakes and I usually use it when refactoring code (check out <a href="http://amix.dk/blog/viewEntry/19361" rel="nofollow">http://amix.dk/blog/viewEntry/19361</a> for more info).