diff options
Diffstat (limited to 'tests/functional/a/arguments.py')
-rw-r--r-- | tests/functional/a/arguments.py | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/tests/functional/a/arguments.py b/tests/functional/a/arguments.py index 29fdbd5ba..81a9bb73d 100644 --- a/tests/functional/a/arguments.py +++ b/tests/functional/a/arguments.py @@ -1,6 +1,6 @@ # pylint: disable=too-few-public-methods, missing-docstring,import-error,wrong-import-position # pylint: disable=wrong-import-order, unnecessary-lambda, consider-using-f-string -# pylint: disable=unnecessary-lambda-assignment, no-self-argument, unused-argument +# pylint: disable=unnecessary-lambda-assignment, no-self-argument, unused-argument, kwarg-superseded-by-positional-arg def decorator(fun): """Decorator""" @@ -278,3 +278,45 @@ class FruitPicker: picker = FruitPicker() picker.pick_apple() picker.pick_pear() + + +def name1(apple, /, **kwargs): + """ + Positional-only parameter with `**kwargs`. + Calling this function with the `apple` keyword should not emit + `redundant-keyword-arg` since it is added to `**kwargs`. + + >>> name1("Red apple", apple="Green apple") + "Red apple" + {"apple": "Green apple"} + """ + print(apple) + print(kwargs) + + +name1("Red apple", apple="Green apple") + + +def name2(apple, /, banana, **kwargs): + """ + Positional-only parameter with positional-or-keyword parameter and `**kwargs`. + """ + + +# `banana` is redundant +# +1:[redundant-keyword-arg] +name2("Red apple", "Yellow banana", apple="Green apple", banana="Green banana") + + +# Test `no-value-for-parameter` in the context of positional-only parameters + +def name3(param1, /, **kwargs): ... +def name4(param1, /, param2, **kwargs): ... +def name5(param1=True, /, **kwargs): ... +def name6(param1, **kwargs): ... + +name3(param1=43) # [no-value-for-parameter] +name3(43) +name4(1, param2=False) +name5() +name6(param1=43) |