MCPcopy Index your code
hub / github.com/python/mypy / ComparisonExpr

Class ComparisonExpr

mypy/nodes.py:2707–2733  ·  view source on GitHub ↗

Comparison expression (e.g. a < b > c < d).

Source from the content-addressed store, hash-verified

2705
2706
2707class ComparisonExpr(Expression):
2708 """Comparison expression (e.g. a < b > c < d)."""
2709
2710 __slots__ = ("operators", "operands", "method_types")
2711
2712 __match_args__ = ("operands", "operators")
2713
2714 operators: list[str]
2715 operands: list[Expression]
2716 # Inferred type for the operator methods (when relevant; None for 'is').
2717 method_types: list[mypy.types.Type | None]
2718
2719 def __init__(self, operators: list[str], operands: list[Expression]) -> None:
2720 super().__init__()
2721 self.operators = operators
2722 self.operands = operands
2723 self.method_types = []
2724
2725 def pairwise(self) -> Iterator[tuple[str, Expression, Expression]]:
2726 """If this comparison expr is "a < b is c == d", yields the sequence
2727 ("<", a, b), ("is", b, c), ("==", c, d)
2728 """
2729 for i, operator in enumerate(self.operators):
2730 yield operator, self.operands[i], self.operands[i + 1]
2731
2732 def accept(self, visitor: ExpressionVisitor[T]) -> T:
2733 return visitor.visit_comparison_expr(self)
2734
2735
2736class SliceExpr(Expression):

Callers 3

visit_CompareMethod · 0.90
visit_comparison_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…