diff options
author | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2011-01-06 10:49:14 +0100 |
---|---|---|
committer | Sylvain Thénault <sylvain.thenault@logilab.fr> | 2011-01-06 10:49:14 +0100 |
commit | a1dc8eb5ef12f566138ff725bba1a63eb3c62cec (patch) | |
tree | f4a25318972569410200d5f185bb6dacd7c7003d | |
parent | 66452a58de50e64258859b3b54a6ddb31c8c9e29 (diff) | |
download | pylint-git-a1dc8eb5ef12f566138ff725bba1a63eb3c62cec.tar.gz |
avoid W0221 or W0222 when *args and **kwargs are in use. Patch by Charles Duffy.
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | checkers/classes.py | 3 | ||||
-rw-r--r-- | test/input/func_noerror_overriden_method_varargs.py | 19 |
3 files changed, 31 insertions, 5 deletions
@@ -1,18 +1,22 @@ ChangeLog for PyLint ==================== -2010-12-16 -- 0.23.0 + -- - * documentation: update, add manpages - * performance: several improvements - * python3: finalize python3 support + * documentation update, add manpages - * W0106: new warning 'Expression "%s" is assigned to nothing' + * several performance improvements + + * finalize python3 support + + * new W0106 warning 'Expression "%s" is assigned to nothing' * drop E0501 and E0502 messages about wrong source encoding: not anymore interesting since it's a syntax error for python >= 2.5 and we now only support this python version and above. + * don't emit W0221 or W0222 when methods as variable arguments (eg *arg + and/or **args). Patch submitted by Charles Duffy. 2010-11-15 -- 0.22.0 diff --git a/checkers/classes.py b/checkers/classes.py index 909316a58..856bad221 100644 --- a/checkers/classes.py +++ b/checkers/classes.py @@ -503,6 +503,9 @@ instance attributes.'} # don't care about functions with unknown argument (builtins) if method1.args.args is None or refmethod.args.args is None: return + # if we use *args, **kwargs, skip the below checks + if method1.args.vararg or method1.args.kwarg: + return if len(method1.args.args) != len(refmethod.args.args): self.add_message('W0221', args=class_type, node=method1) elif len(method1.args.defaults) < len(refmethod.args.defaults): diff --git a/test/input/func_noerror_overriden_method_varargs.py b/test/input/func_noerror_overriden_method_varargs.py new file mode 100644 index 000000000..afe30863f --- /dev/null +++ b/test/input/func_noerror_overriden_method_varargs.py @@ -0,0 +1,19 @@ +# pylint: disable=R0201,R0903 +"""docstring""" + +__revision__ = 1 + +class SuperClass(object): + """docstring""" + def impl(self, arg1, arg2): + """docstring""" + return arg1 + arg2 + +class MyClass(SuperClass): + """docstring""" + def impl(self, *args, **kwargs): + """docstring""" + # ...do stuff here... + super(MyClass, self).impl(*args, **kwargs) + +# ...do stuff here... |