Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
keyword-arg-before-vararg should not be raised with python2 #1835
Steps to reproduce
def test(a, b=1, c=2, *args, **kwargs): print(args)
def test(a, *args, b=1, c=2, **kwargs): print(args)
As per 1.8.1 release notes:
I think this warning shouldn't be raised in python2.
pylint --version output
pylint --version Using config file /ifs/work/leukgen/home/s/repos/toil_battenberg/.pylintrc pylint 1.8.1, astroid 1.6.0 Python 2.7.11 (default, Jan 11 2016, 13:50:06) [GCC 4.4.7 20120313 (Red Hat 4.4.7-16)]
It's not a great solution because the defaults aren't included in the function signature but I would do the following in this case:
kwargs.setdefault('b', 1) kwargs.setdefault('c', 2)
It's not ideal, but mixing keyword arguments and variable arguments can get messy really quickly. So I think that using setdefault is a better solution, especially if you document the new default value in the docstring.
This is a matter of opinion though so feel free to add a new option to cover this case. The 1.9 branch is where the Python 2 compatible version exists.