MCPcopy Index your code
hub / github.com/ipython/ipython / _triple_quote_mask

Method _triple_quote_mask

IPython/core/inputtransformer2.py:89–109  ·  view source on GitHub ↗

Return a boolean mask: True if the corresponding line is considered inside a triple-quoted string literal. This is intentionally heuristic (fast + good enough for paste handling).

(self, lines: List[str])

Source from the content-addressed store, hash-verified

87
88
89 def _triple_quote_mask(self, lines: List[str]) -> List[bool]:
90 """
91 Return a boolean mask: True if the corresponding line is considered
92 inside a triple-quoted string literal.
93
94 This is intentionally heuristic (fast + good enough for paste handling).
95 """
96 mask: List[bool] = []
97 in_triple: str | None = None # either ''' or """
98 for line in lines:
99 mask.append(in_triple is not None)
100 # Toggle state for each occurrence of """ or ''' in the line.
101 for m in self._triple_quote_re.finditer(line):
102 q = m.group(1)
103 if in_triple is None:
104 in_triple = q
105 mask[-1] = True # current line is inside triple quotes
106 elif in_triple == q:
107 in_triple = None
108 # else: ignore mismatched triple quote while inside
109 return mask
110
111
112 def _strip(self, lines):

Callers 1

__call__Method · 0.95

Calls 1

groupMethod · 0.80

Tested by

no test coverage detected