1
0
forked from VimPlug/jedi

Wrong var_args with a star star function.

This commit is contained in:
Dave Halter
2014-06-06 16:49:53 +02:00
parent cb430c4c36
commit f061de0f74
3 changed files with 17 additions and 5 deletions

View File

@@ -16,6 +16,7 @@ CODES = {
'type-error-too-few-arguments': (6, TypeError, None), 'type-error-too-few-arguments': (6, TypeError, None),
'type-error-keyword-argument': (7, TypeError, None), 'type-error-keyword-argument': (7, TypeError, None),
'type-error-multiple-values': (8, TypeError, None), 'type-error-multiple-values': (8, TypeError, None),
'type-error-star-star-mapping': (9, TypeError, None),
} }

View File

@@ -227,7 +227,8 @@ def _unpack_var_args(evaluator, var_args, params):
for array in evaluator.eval_expression_list(expression_list[1:]): for array in evaluator.eval_expression_list(expression_list[1:]):
# Merge multiple kwargs dictionaries, if used with dynamic # Merge multiple kwargs dictionaries, if used with dynamic
# parameters. # parameters.
for name, (key, value) in _star_star_dict(array).items(): s = _star_star_dict(evaluator, array, expression_list[1:])
for name, (key, value) in s.items():
try: try:
dct[name][1].add(value) dct[name][1].add(value)
except KeyError: except KeyError:
@@ -275,9 +276,9 @@ def _iterate_star_args(array):
pass # TODO need a warning here. pass # TODO need a warning here.
def _star_star_dict(array): def _star_star_dict(evaluator, array, expression_list):
dct = {} dct = {}
if isinstance(array, iterable.Array): if isinstance(array, iterable.Array) and array.type == pr.Array.DICT:
for key_stmt, value_stmt in array.items(): for key_stmt, value_stmt in array.items():
# first index, is the key if syntactically correct # first index, is the key if syntactically correct
call = key_stmt.expression_list()[0] call = key_stmt.expression_list()[0]
@@ -294,8 +295,11 @@ def _star_star_dict(array):
pass pass
# raise warning # raise warning
else: else:
pass if expression_list:
# raise warning m = "TypeError: type object argument after ** must be a mapping, not %s" \
% (array)
analysis.add(evaluator, 'type-error-star-star-mapping',
expression_list[0], message=m)
return dct return dct

View File

@@ -95,3 +95,10 @@ mixed2(3, 4, 5)
mixed2(3, 4, c=5) mixed2(3, 4, c=5)
#! 6 type-error-multiple-values #! 6 type-error-multiple-values
mixed2(3, b=5) mixed2(3, b=5)
# -----------------
# plain wrong arguments
# -----------------
#! 12 type-error-star-star-mapping
simple(1, **[])