Description
Originally reported by: the mulhern (BitBucket: the_mulhern)
For the following example, error
"Passing unexpected keyword argument 'foo' in function call (unexpected-keyword-arg)"
is reported, correctly.
#!python
def junk1(junk=None):
print("%s" % junk)
def main():
junk1(foo=2)
For the example below, no such error is reported, due to the use of keyword args parameter. This is also correct.
#!python
def junk1(junk=None, *args, **kwargs):
print("%s" % junk)
def main():
junk1(foo=2)
In the following example, the decorator supplies the foo argument, but the analysis still reports
"Passing unexpected keyword argument 'foo' in function call (unexpected-keyword-arg)"
which is incorrect. It should be able to detect that foo is now supplied, and give no error.
#!python
def decorator(f):
def new_func(foo=3):
f(junk=foo)
return new_func
@decorator
def junk1(junk=None):
print("%s" % junk)
def main():
junk1(foo=2)
And for the following example it still reports
"Passing unexpected keyword argument 'foo' in function call (unexpected-keyword-arg)"
although in this case it should give up due to the use of keyword arguments param, as
in the second example.
#!python
def decorator(f):
def new_func(**kwargs):
f(junk=kwargs["foo"])
return new_func
@decorator
def junk1(junk=None):
print("%s" % junk)
def main():
junk1(foo=2)