except InferenceError: break def for_assigned_stmts(self, node, context=None, asspath=None): if asspath is None: for lst in self.iter.infer(context): if isinstance(lst, (nodes.Tuple, nodes.List)): for item in lst.elts: yield item else: for infered in _resolve_looppart(self.iter.infer(context), asspath, context): yield infered nodes.For.assigned_stmts = raise_if_nothing_infered(for_assigned_stmts) nodes.Comprehension.assigned_stmts = raise_if_nothing_infered(for_assigned_stmts) def mulass_assigned_stmts(self, node, context=None, asspath=None): if asspath is None: asspath = [] asspath.insert(0, self.elts.index(node)) return self.parent.assigned_stmts(self, context, asspath) nodes.Tuple.assigned_stmts = mulass_assigned_stmts nodes.List.assigned_stmts = mulass_assigned_stmts def assend_assigned_stmts(self, context=None): return self.parent.assigned_stmts(self, context=context) nodes.AssName.assigned_stmts = assend_assigned_stmts
for callee in self.func.infer(context): with context.scope( callcontext=CallContext(self.args, self.starargs, self.kwargs), boundnode=None, ): if callee is YES: yield callee continue try: if hasattr(callee, 'infer_call_result'): for infered in callee.infer_call_result(self, context): yield infered except InferenceError: ## XXX log error ? continue nodes.CallFunc._infer = path_wrapper(raise_if_nothing_infered(infer_callfunc)) def infer_import(self, context=None, asname=True, lookupname=None): """infer an Import node: return the imported module/object""" if lookupname is None: raise InferenceError() if asname: yield self.do_import_module(self.real_name(lookupname)) else: yield self.do_import_module(lookupname) nodes.Import._infer = path_wrapper(infer_import) def infer_name_module(self, name): context = InferenceContext() return self.infer(context, asname=False, lookupname=name)
break def for_assigned_stmts(self, node, context=None, asspath=None): if asspath is None: for lst in self.iter.infer(context): if isinstance(lst, (nodes.Tuple, nodes.List)): for item in lst.elts: yield item else: for infered in _resolve_looppart(self.iter.infer(context), asspath, context): yield infered nodes.For.assigned_stmts = raise_if_nothing_infered(for_assigned_stmts) nodes.Comprehension.assigned_stmts = raise_if_nothing_infered( for_assigned_stmts) def mulass_assigned_stmts(self, node, context=None, asspath=None): if asspath is None: asspath = [] asspath.insert(0, self.elts.index(node)) return self.parent.assigned_stmts(self, context, asspath) nodes.Tuple.assigned_stmts = mulass_assigned_stmts nodes.List.assigned_stmts = mulass_assigned_stmts