MCPcopy Create free account
hub / github.com/psf/black / parse

Method parse

src/black/trans.py:2253–2269  ·  view source on GitHub ↗

Pre-conditions: * @leaves[@string_idx].type == token.STRING Returns: The index directly after the last leaf which is apart of the string trailer, if a "trailer" exists. OR @string_idx + 1, if no string "trailer" exists

(self, leaves: List[Leaf], string_idx: int)

Source from the content-addressed store, hash-verified

2251 self._unmatched_lpars = 0
2252
2253 def parse(self, leaves: List[Leaf], string_idx: int) -> int:
2254 """
2255 Pre-conditions:
2256 * @leaves[@string_idx].type == token.STRING
2257
2258 Returns:
2259 The index directly after the last leaf which is apart of the string
2260 trailer, if a "trailer" exists.
2261 OR
2262 @string_idx + 1, if no string "trailer" exists.
2263 """
2264 assert leaves[string_idx].type == token.STRING
2265
2266 idx = string_idx + 1
2267 while idx < len(leaves) and self._next_state(leaves[idx]):
2268 idx += 1
2269 return idx
2270
2271 def _next_state(self, leaf: Leaf) -> bool:
2272 """

Callers 10

do_matchMethod · 0.95
do_transformMethod · 0.95
do_splitter_matchMethod · 0.95
_assert_matchMethod · 0.95
_assign_matchMethod · 0.95
_dict_or_lambda_matchMethod · 0.95
mask_cellFunction · 0.45
replace_cell_magicsFunction · 0.45
replace_magicsFunction · 0.45
parse_single_versionFunction · 0.45

Calls 1

_next_stateMethod · 0.95

Tested by

no test coverage detected