diff --git a/jedi/evaluate_representation.py b/jedi/evaluate_representation.py index aff57a49..4af13a96 100644 --- a/jedi/evaluate_representation.py +++ b/jedi/evaluate_representation.py @@ -495,23 +495,38 @@ class Execution(Executable): """ Create a param with the original scope (of varargs) as parent. """ + # TODO remove array and param and just put the values of the \ + # statement into the values of the param - it's as simple as that. if isinstance(self.var_args, pr.Array): parent = self.var_args.parent start_pos = self.var_args.start_pos else: parent = self.base start_pos = None - # create an Array (-> container for the statement) - arr = pr.Array(self.module, start_pos, pr.Array.NOARRAY, parent) - arr.values = values - arr.keys = keys - arr.type = array_type new_param = copy.copy(param) + new_param.is_generated = True if parent is not None: new_param.parent = parent - new_param._commands = [arr] - new_param.is_generated = True + + if array_type is not None: + # create an Array (-> needed for *args/**kwargs tuples/dicts) + arr = pr.Array(self.module, start_pos, array_type, parent) + """ + for i, value in enumerate(values): # TODO delete? + try: + keys[i] + except IndexError: + pass + """ + arr.values = values + arr.keys = keys + arr.type = array_type + + new_param._commands = [arr] + else: + new_param._commands = values + name = copy.copy(param.get_name()) name.parent = new_param return name diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index 53e0ac9c..7850d941 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -24,7 +24,7 @@ import re import tokenize from _compatibility import next, literal_eval, cleandoc, Python3Method, \ - property + property, unicode import common import debug @@ -711,7 +711,7 @@ class Statement(Simple): def get_code(self, new_line=True): def assemble(command_list, assignment=None): - pieces = [c.get_code() if isinstance(c, Simple) else c + pieces = [c.get_code() if isinstance(c, Base) else c for c in command_list] if assignment is None: return ''.join(pieces) @@ -763,7 +763,7 @@ class Statement(Simple): it and make it nicer, that would be cool :-) """ def is_assignment(tok): - return tok is not None and tok.endswith('=') \ + return isinstance(tok, (str, unicode)) and tok.endswith('=') \ and not tok in ['>=', '<=', '==', '!='] def parse_array(token_iterator, array_type, start_pos, add_el=None):