On 19 novembre 18:22, James Lingard wrote: > Below is a new pylint checker that checks that the arguments passed to a > function call match the function's formal parameters. For example, on the > following file: > > def f( a, b=1 ): > print a, b > f() > f( 1, 2, 3 ) > f( a=1, a=2 ) > f( 1, c=3 ) > f( 1, a=2 ) > > the checker produces the following output: > > ************* Module xyz > E9700: 3: No value passed for parameter 'a' in function call > E9701: 4: Two many positional arguments for function call > E9702: 5: Duplicate keyword argument 'a' in function call > E9703: 6: Passing unexpected keyword argument 'c' in function call > E9704: 7: Multiple values passed for parameter 'a' in function call > > It handles function definitions that use *args and **kwargs. It handles > function calls that pass *args and/or **kwargs somewhat conservatively, only > warning if there are no possible values of the args and kwargs that will > make the call succeed -- it doesn't attempt to do any inference on the args > or kwargs. > > The checker also checks calls to bound and unbound methods (including static > and class methods) and lambda functions. > > I've tested this on a large body of code, and it's successfully found > several errors. The only false positives I'm aware of are in the following > case: > > class Foo( object ): > def f( self ): pass > g = f > > The checker will complain that a call to "Foo().g()" is missing the "self" > parameter, since inference claims that Foo().g is a function definition, not > a bound method. > > As before, let me know if you're interested in incorporating this into > pylint. If so, I'd be happy to work on some unit test cases, and I'd love > to hear any feedback.
This is great, and I'm definitly interested in incorporating it. I wouldn't put it in a separated checker though, rather in the 'base' or 'typecheck' checker. Regarding tests, see pylint functional test system : input python files in test/input, expected messages text file in test/messages. Also, to be consistent with pylint code could you use 'under_case' instead of 'camelCalse' please ? Thank you very much for your contribution, I think a lot of people will enjoy this new functionality (and I am among them!) :D BTW, rememer next wednesday (25th) is the first public pylint bug day! -- Sylvain Thénault LOGILAB, Paris (France) Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations Développement logiciel sur mesure: http://www.logilab.fr/services CubicWeb, the semantic web framework: http://www.cubicweb.org _______________________________________________ Python-Projects mailing list Python-Projects@lists.logilab.org http://lists.logilab.org/mailman/listinfo/python-projects