diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-09 00:35:34 +0300 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2015-10-09 00:35:34 +0300 |
commit | 0614931796a4d9c48a69eb9b4558131b8aec74ed (patch) | |
tree | fb59e2be7ea6391249dc70a406894e460f066110 /pylint/test/functional/unpacking_generalizations.py | |
parent | 79b9ca212bb70b805dc1100417bb3d96923d2b9e (diff) | |
download | pylint-git-0614931796a4d9c48a69eb9b4558131b8aec74ed.tar.gz |
Add a new error, 'repeated-keyword', when a keyword argument is passed multiple times into a function call.
This is similar with redundant-keyword-arg, but it's mildly different
that it needs to be a separate error. This change also uses a CallSite for
understanding the arguments that were passed into a function call, since
with this we can make sense about multiple starred arguments passed into
(PEP 448).
Diffstat (limited to 'pylint/test/functional/unpacking_generalizations.py')
-rw-r--r-- | pylint/test/functional/unpacking_generalizations.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/pylint/test/functional/unpacking_generalizations.py b/pylint/test/functional/unpacking_generalizations.py new file mode 100644 index 000000000..1c5fb16b8 --- /dev/null +++ b/pylint/test/functional/unpacking_generalizations.py @@ -0,0 +1,29 @@ +"""Various tests for unpacking generalizations added in Python 3.5"""
+
+# pylint: disable=missing-docstring, invalid-name
+
+def func_variadic_args(*args):
+ return args
+
+
+def func_variadic_positional_args(a, b, *args):
+ return a, b, args
+
+def func_positional_args(a, b, c, d):
+ return a, b, c, d
+
+
+func_variadic_args(*(2, 3), *(3, 4), *(4, 5))
+func_variadic_args(1, 2, *(2, 3), 2, 3, *(4, 5))
+func_variadic_positional_args(1, 2, *(4, 5), *(5, 6))
+func_variadic_positional_args(*(2, 3), *(4, 5), *(5, 6))
+func_variadic_positional_args(*(2, 3))
+func_variadic_positional_args(*(2, 3, 4))
+func_variadic_positional_args(1, 2, 3, *(3, 4))
+
+func_positional_args(*(2, 3, 4), *(2, 3)) # [too-many-function-args]
+func_positional_args(*(1, 2), 3) # [no-value-for-parameter]
+func_positional_args(1, *(2, ), 3, *(4, 5)) # [too-many-function-args]
+func_positional_args(1, 2, c=24, d=32, **{'d': 32}) # [repeated-keyword]
+# +1: [repeated-keyword,repeated-keyword]
+func_positional_args(1, 2, c=24, **{'c': 34, 'd': 33}, **{'d': 24})
|