MCPcopy
hub / github.com/psf/black / parse

Method parse

src/black/trans.py:2423–2439  ·  view source on GitHub ↗

Pre-conditions: * @leaves[@string_idx].type == token.STRING Returns: The index directly after the last leaf which is a part 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

2421 self._unmatched_lpars = 0
2422
2423 def parse(self, leaves: list[Leaf], string_idx: int) -> int:
2424 """
2425 Pre-conditions:
2426 * @leaves[@string_idx].type == token.STRING
2427
2428 Returns:
2429 The index directly after the last leaf which is a part of the string
2430 trailer, if a "trailer" exists.
2431 OR
2432 @string_idx + 1, if no string "trailer" exists.
2433 """
2434 assert leaves[string_idx].type == token.STRING
2435
2436 idx = string_idx + 1
2437 while idx < len(leaves) and self._next_state(leaves[idx]):
2438 idx += 1
2439 return idx
2440
2441 def _next_state(self, leaf: Leaf) -> bool:
2442 """

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