MCPcopy
hub / github.com/python/mypy / OpExpr

Class OpExpr

mypy/nodes.py:2648–2697  ·  view source on GitHub ↗

Binary operation. The dot (.), [] and comparison operators have more specific nodes.

Source from the content-addressed store, hash-verified

2646
2647
2648class OpExpr(Expression):
2649 """Binary operation.
2650
2651 The dot (.), [] and comparison operators have more specific nodes.
2652 """
2653
2654 __slots__ = (
2655 "op",
2656 "left",
2657 "right",
2658 "method_type",
2659 "right_always",
2660 "right_unreachable",
2661 "analyzed",
2662 "as_type",
2663 )
2664
2665 __match_args__ = ("left", "op", "right")
2666
2667 op: str # TODO: Enum?
2668 left: Expression
2669 right: Expression
2670 # Inferred type for the operator method type (when relevant).
2671 method_type: mypy.types.Type | None
2672 # Per static analysis only: Is the right side going to be evaluated every time?
2673 right_always: bool
2674 # Per static analysis only: Is the right side unreachable?
2675 right_unreachable: bool
2676 # Used for expressions that represent a type "X | Y" in some contexts
2677 analyzed: TypeAliasExpr | None
2678 # If this value expression can also be parsed as a valid type expression,
2679 # represents the type denoted by the type expression.
2680 # None means "is not a type expression".
2681 as_type: NotParsed | mypy.types.Type | None
2682
2683 def __init__(
2684 self, op: str, left: Expression, right: Expression, analyzed: TypeAliasExpr | None = None
2685 ) -> None:
2686 super().__init__()
2687 self.op = op
2688 self.left = left
2689 self.right = right
2690 self.method_type = None
2691 self.right_always = False
2692 self.right_unreachable = False
2693 self.analyzed = analyzed
2694 self.as_type = NotParsed.VALUE
2695
2696 def accept(self, visitor: ExpressionVisitor[T]) -> T:
2697 return visitor.visit_op_expr(self)
2698
2699
2700# Expression subtypes that could represent the root of a valid type expression.

Callers 7

groupMethod · 0.90
visit_BinOpMethod · 0.90
visit_call_exprMethod · 0.90
visit_op_exprMethod · 0.90
read_expressionFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…