def unpack_infer(stmt, context=None): """return an iterator on nodes infered by the given statement if the infered value is a list or a tuple, recurse on it to get values infered by its content """ if isinstance(stmt, (List, Tuple)): # XXX loosing context return chain(*imap(unpack_infer, stmt.nodes)) infered = stmt.infer(context).next() if infered is stmt: return iter((stmt, )) return chain(*imap(unpack_infer, stmt.infer(context)))
def unpack_infer(stmt, context=None): """return an iterator on nodes infered by the given statement if the infered value is a list or a tuple, recurse on it to get values infered by its content """ if isinstance(stmt, (List, Tuple)): # XXX loosing context return chain(*imap(unpack_infer, stmt.nodes)) infered = stmt.infer(context).next() if infered is stmt: return iter( (stmt,) ) return chain(*imap(unpack_infer, stmt.infer(context)))
def _wrap_attr(self, attrs): """wrap bound methods of attrs in a InstanceMethod proxies""" # Guess which attrs are used in inference. def wrap(attr): if isinstance(attr, Function) and attr.type == 'method': return InstanceMethod(attr) else: return attr return imap(wrap, attrs)