lint for Python?

Aaron "Castironpi" Brady castironpi at gmail.com
Sun Oct 5 22:23:41 EDT 2008


On Oct 5, 8:53 am, Pat <P... at junk.net> wrote:
> Miki wrote:
> > Hello,
>
> >> In module one, I have a function:
>
> >> def foo( host, userid, password ):
> >>      pass
>
> >> In module two, I call that function:
>
> >> foo( userid, password)
>
> >> lint doesn't find that error and it won't be caught until it's called
> >> while the program is running.
> > pychecker does find these kind of errors.
>
> Before posting my original question, I tried pychecker and it didn't
> catch that error.

Sorry for the multiple posting earlier (you heard me right, not 2 but
3 identical).  The basic checker of walking a parse tree, doing
imports by hand, and checking call signatures isn't awful.  60 lines.

/File:

from ng23mod1 import foo as foo
userid, password= 'abc', '123'
import random
foo( 'localhost', userid, password)
if random.uniform( 0, 1 )< .01: # 1 out of 100 times
    foo( userid, password)

/Checker output:

foo ['Str', 'Name', 'Name'] found 3 expected
random ['Num', 'Num'] found 2 expected
foo ['Name', 'Name'] found 3 expected

But it's extremely delicate and at 60 lines only checks fixed-length
call signatures and functions, not even methods.  If you have a
statement:

x= y.z()

Then 'y' has to be defined somewhere, so you could make some educated
guesses that way.



More information about the Python-list mailing list