Whether whitespace around `**` should be removed.
(node: LN)
| 553 | |
| 554 | |
| 555 | def 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 | |
| 574 | def is_docstring(node: NL) -> bool: |
no test coverage detected