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

Function is_simple_exponentiation

src/black/nodes.py:555–571  ·  view source on GitHub ↗

Whether whitespace around `**` should be removed.

(node: LN)

Source from the content-addressed store, hash-verified

553
554
555def is_simple_exponentiation(node: LN) -> bool:
556 """Whether whitespace around `**` should be removed."""
557
558 def is_simple(node: LN) -> bool:
559 if isinstance(node, Leaf):
560 return node.type in (token.NAME, token.NUMBER, token.DOT, token.DOUBLESTAR)
561 elif node.type == syms.factor: # unary operators
562 return is_simple(node.children[1])
563 else:
564 return all(is_simple(child) for child in node.children)
565
566 return (
567 node.type == syms.power
568 and len(node.children) >= 3
569 and node.children[-2].type == token.DOUBLESTAR
570 and is_simple(node)
571 )
572
573
574def is_docstring(node: NL) -> bool:

Callers 1

whitespaceFunction · 0.85

Calls 1

is_simpleFunction · 0.85

Tested by

no test coverage detected