BinOp#

class astroid.nodes.BinOp(op: str, lineno: int, col_offset: int, parent: NodeNG, *, end_lineno: int | None, end_col_offset: int | None)[source]#

Bases: OperatorNode

Class representing an ast.BinOp node.

A BinOp node is an application of a binary operator.

>>> import astroid
>>> node = astroid.extract_node('a + b')
>>> node
<BinOp l.1 at 0x7f23b2e8cfd0>
get_children()[source]#

Get the child nodes below this node.

left: NodeNG#

What is being applied to the operator on the left side.

op#

The operator.

op_left_associative() bool[source]#
op_precedence()[source]#
postinit(left: NodeNG, right: NodeNG) None[source]#
right: NodeNG#

What is being applied to the operator on the right side.

type_errors(context: InferenceContext | None = None)[source]#

Get a list of type errors which can occur during inference.

Each TypeError is represented by a BadBinaryOperationMessage, which holds the original exception.

Returns:

The list of possible type errors.

Return type:

list(BadBinaryOperationMessage)