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>
- op¶
The operator.
- type_errors(context: InferenceContext | None = None) list[BadUnaryOperationMessage] [source]¶
Get a list of type errors which can occur during inference.
Each TypeError is represented by a
BadUnaryOperationMessage
, which holds the original exception.If any inferred result is uninferable, an empty list is returned.