Hi, The idea of plugin is very simple and I felt the need of it in my organization's code base where we use python 2.7 to write the tests.
There are a lot of functions which looks like this: def foo( var1, name1=value, *args ): The problem that I want to deal with is that we should not have keyword arguments( *name1* ) before positional arguments( **args* ). Although the function can still be called by passing *name1* as positional argument but there would be no way to not specify *name1* but specify **args*. def foo(a, b=3, *args): print a, b, args Case1: a = 0, b = 2, args = (4, 5) foo(0, 2, 4, 5) => 0 2 (4, 5) Case2: a = 0, b = <default_value>, args = (4, 5) foo(0, 4, 5) => 0 4 (5, ) ==> args list modified as well as value of 'b' And of course, we cant do this: foo(0, b=2, 4, 5) I plan to put this in design_analysis checker and the check looks like this: from astroid.test_utils import extract_node n = extract_node(''' def test(a, b=2, *args, c=3, **kwargs): pass ''') *if n.args.defaults and n.args.varargs:* print <ErrMsg> I already checked it by loading this plugin as an external plugin in my pylintrc file and it worked as expected. Claudio suggested that this might be a useful check, so I plan to merge it in the developing code-base. Do let me know your thoughts! On Wed, Aug 5, 2015 at 1:49 PM, Ahirnish Pareek <ahirn...@arista.com> wrote: > Hi, > > I have never patched anything to the open-source code and I am confused as > to what are the right steps to follow. I need to patch a function argument > related checker into the pylint code base. Can someone point me to the > steps need to follow to ensure my changes go upstream? > > Thanks. > > On Fri, Jul 3, 2015 at 3:02 PM, Claudiu Popa <pcmantic...@gmail.com> > wrote: > >> On Thu, Jul 2, 2015 at 9:45 AM, Ahirnish Pareek <ahirn...@arista.com> >> wrote: >> > Hi all, >> > >> > I was wondering if there's a pattern to calculate Pylint's message-id >> > numbers? I know that first alphabet indicates if its a warning, error, >> > convention, refactor or fatal but how do we come up with 4-digit number >> > after that? >> > >> > Like - E1605. E = Error but what is 1605? >> > >> > Thanks. >> >> >> Base id of standard checkers (used in msg and report ids): >> 01: base >> 02: classes >> 03: format >> 04: import >> 05: misc >> 06: variables >> 07: exceptions >> 08: similar >> 09: design_analysis >> 10: newstyle >> 11: typecheck >> 12: logging >> 13: string_format >> 14: string_constant >> 15: stdlib >> 16: python3 >> >> So for E1605, that would be from the python 3 checker. Since it's pretty >> hard to remember all this, the message ids will be deprecated at some >> point, in favor of using symbolic names. >> > > > > -- > Regards, > Ahirnish > -- Regards, Ahirnish
_______________________________________________ code-quality mailing list code-quality@python.org https://mail.python.org/mailman/listinfo/code-quality