def visit_binop(self, node: astroid.BinOp) -> None: left_inf, right_inf = node.left.inf_type, node.right.inf_type method_name = BINOP_TO_METHOD[node.op] # attempt to obtain a common arithmetic type arithm_type = self._arithm_convert(node, method_name, left_inf, right_inf) if arithm_type: node.inf_type = arithm_type else: rev_method_name = BINOP_TO_REV_METHOD[node.op] l_type = self._handle_call(node, method_name, left_inf, right_inf) r_type = self._handle_call(node, rev_method_name, right_inf, left_inf) if self.type_store.is_descendant(right_inf.getValue(), left_inf.getValue()): if isinstance(r_type, TypeFail) and isinstance( l_type, TypeInfo): node.inf_type = l_type else: node.inf_type = r_type else: if isinstance(l_type, TypeFail) and isinstance( r_type, TypeInfo): node.inf_type = r_type else: node.inf_type = l_type
def visit_binop(self, node: astroid.BinOp) -> None: method_name = BINOP_TO_METHOD[node.op] arg_types = [ node.left.inf_type.getValue(), node.right.inf_type.getValue() ] node.inf_type = self._handle_call(node, method_name, *arg_types, error_func=binop_error_message)
def create_for_node_with_new_iter(old_for_node: ast.For, new_iter: ast.BinOp) -> ast.For: new_for_node = ast.For(lineno=old_for_node.lineno, col_offset=old_for_node.col_offset, parent=old_for_node.parent,) new_iter.parent = new_for_node new_for_node.postinit( target=old_for_node.target, iter=new_iter, body=old_for_node.body, orelse=old_for_node.orelse, ) return new_for_node
def visit_binop(self, node: astroid.BinOp) -> None: left_inf, right_inf = node.left.inf_type, node.right.inf_type method_name = BINOP_TO_METHOD[node.op] # attempt to obtain a common arithmetic type arithm_type = self._arithm_convert(node, method_name, left_inf, right_inf) if arithm_type: node.inf_type = arithm_type else: rev_method_name = BINOP_TO_REV_METHOD[node.op] l_type = self._handle_call(node, method_name, left_inf, right_inf) r_type = self._handle_call(node, rev_method_name, right_inf, left_inf) if self.type_store.is_descendant(right_inf.getValue(), left_inf.getValue()): if isinstance(r_type, TypeFail) and isinstance(l_type, TypeInfo): node.inf_type = l_type else: node.inf_type = r_type else: if isinstance(l_type, TypeFail) and isinstance(r_type, TypeInfo): node.inf_type = r_type else: node.inf_type = l_type