def _imitate_items(self): items = set( FakeSequence( self.evaluator, 'tuple', (context.LazyKnownContexts(keys), context.LazyKnownContexts(values)) ) for keys, values in self._iterate() ) return create_evaluated_sequence_set(self.evaluator, items, sequence_type='list')
def _execute_array_values(evaluator, array): """ Tuples indicate that there's not just one return value, but the listed ones. `(str, int)` means that it returns a tuple with both types. """ if isinstance(array, SequenceLiteralContext): values = [] for lazy_context in array.py__iter__(): objects = unite(_execute_array_values(evaluator, typ) for typ in lazy_context.infer()) values.append(context.LazyKnownContexts(objects)) return set([FakeSequence(evaluator, array.array_type, values)]) else: return array.execute_evaluated()
def py__iter__(self): """ While values returns the possible values for any array field, this function returns the value for a certain index. """ if self.array_type == 'dict': # Get keys. types = set() for k, _ in self._items(): types |= self._defining_context.eval_node(k) # We don't know which dict index comes first, therefore always # yield all the types. for _ in types: yield context.LazyKnownContexts(types) else: for node in self._items(): yield context.LazyTreeContext(self._defining_context, node) for addition in check_array_additions(self._defining_context, self): yield addition
def unpack(self, funcdef=None): for values in self._values_list: yield None, context.LazyKnownContexts(values)
def _imitate_values(self): lazy_context = context.LazyKnownContexts(self.dict_values()) return set([FakeSequence(self.evaluator, 'list', [lazy_context])])
def py__iter__(self): for keys, values in self._iterate(): yield context.LazyKnownContexts(keys)
def py__iter__(self): for set_ in self._iterate(): yield context.LazyKnownContexts(set_)