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

Method is_complex_subscript

src/black/lines.py:429–446  ·  view source on GitHub ↗

Return True iff `leaf` is part of a slice with non-trivial exprs.

(self, leaf: Leaf)

Source from the content-addressed store, hash-verified

427 )
428
429 def is_complex_subscript(self, leaf: Leaf) -> bool:
430 """Return True iff `leaf` is part of a slice with non-trivial exprs."""
431 open_lsqb = self.bracket_tracker.get_open_lsqb()
432 if open_lsqb is None:
433 return False
434
435 subscript_start = open_lsqb.next_sibling
436
437 if isinstance(subscript_start, Node):
438 if subscript_start.type == syms.listmaker:
439 return False
440
441 if subscript_start.type == syms.subscriptlist:
442 subscript_start = child_towards(subscript_start, leaf)
443
444 return subscript_start is not None and any(
445 n.type in TEST_DESCENDANTS for n in subscript_start.pre_order()
446 )
447
448 def enumerate_with_length(
449 self, is_reversed: bool = False

Callers 1

appendMethod · 0.95

Calls 3

child_towardsFunction · 0.90
get_open_lsqbMethod · 0.80
pre_orderMethod · 0.45

Tested by

no test coverage detected