UnaryOp#

class astroid.nodes.UnaryOp(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.UnaryOp node.

>>> import astroid
>>> node = astroid.extract_node('-5')
>>> node
<UnaryOp l.1 at 0x7f23b2e4e198>
get_children()[source]#

Get the child nodes below this node.

op#

The operator.

op_precedence()[source]#
operand: NodeNG#

What the unary operator is applied to.

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

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

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

Returns:

The list of possible type errors.

Return type:

list(BadUnaryOperationMessage)