-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Labels
DecoratorsFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Description
Bug description
Just tried this out with the latest version of the main branch (any version after bfeca4c) and there seems to be a case where #5547 is still raising a false positive unexpected-keyword-arg error.
def example_decorator(*new_func_args, **new_func_kwargs):
def decorator(func):
def wrapper(*args, **kwargs):
print_me = kwargs.pop("print_me", None)
def inner(*inner_args, **inner_kwargs):
print(print_me)
return func(*inner_args, **inner_kwargs)
return inner(*args, **kwargs)
return wrapper
if len(new_func_args) == 1 and len(new_func_kwargs) == 0 and callable(new_func_args[0]):
return decorator(new_func_args[0])
return decorator
@example_decorator
def example_func(num):
return num ** 2
example_func(6, print_me="hello")(Note that no error is raised by pylint if we remove the top-level function (example_decorator). The reason for someone to define the decorator this way is so that it's possible to use the bare @example_decorator, as well as with arguments @example_decorator(foo=1).)
Using pylint on commit hash e75e37a, this is the error that's printed out:
E1123: Unexpected keyword argument 'print_me' in function call (unexpected-keyword-arg)
Calling example_func works fine:
>>> example_task(6, print_me="hello")
hello
36
Command used
pylint a.pyPylint output
************* Module a
E1123: Unexpected keyword argument 'print_me' in function call (unexpected-keyword-arg)Expected behavior
No unexpected-keyword-arg error raised
Pylint version
current pylint version in the `main` branch (set for 2.13.0)LuminairPrime and gubenkoved
Metadata
Metadata
Assignees
Labels
DecoratorsFalse Positive 🦟A message is emitted but nothing is wrong with the codeA message is emitted but nothing is wrong with the codeNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation