True when `line` opens a control statement whose body must be on the next physical line (i.e. it does not end with `{` and is not a one-liner with a `;` body).
(line: str)
| 599 | |
| 600 | |
| 601 | def _is_brace_free_control(line: str) -> bool: |
| 602 | """True when `line` opens a control statement whose body must be on the |
| 603 | next physical line (i.e. it does not end with `{` and is not a one-liner |
| 604 | with a `;` body).""" |
| 605 | sanitized = _strip_eol_comment(line) |
| 606 | if not sanitized: |
| 607 | return False |
| 608 | if sanitized.endswith("{") or sanitized.endswith(";"): |
| 609 | return False |
| 610 | if not _BRACE_FREE_CONTROL_RE.match(sanitized): |
| 611 | return False |
| 612 | # Reject pathological matches where the regex's greedy `.*` swallowed |
| 613 | # an unbalanced paren run (e.g. `if (cond` continued on next line). |
| 614 | return sanitized.count("(") == sanitized.count(")") |
| 615 | |
| 616 | |
| 617 | def _line_indent(line: str) -> int: |
no test coverage detected