Inside each object body, `id:` must be the first non-comment/blank content line and must be followed by one blank line. Returns (violations, raw_line_indices) — the second list contains indices in physical-line space after which a blank line needs inserting to satisfy the id-blank-li
(
lines: list[LogicalLine], path: Path
)
| 777 | |
| 778 | |
| 779 | def check_id_placement( |
| 780 | lines: list[LogicalLine], path: Path |
| 781 | ) -> tuple[list[Violation], list[int]]: |
| 782 | """Inside each object body, `id:` must be the first non-comment/blank |
| 783 | content line and must be followed by one blank line. Returns |
| 784 | (violations, raw_line_indices) — the second list contains indices in |
| 785 | physical-line space after which a blank line needs inserting to satisfy |
| 786 | the id-blank-line rule.""" |
| 787 | violations: list[Violation] = [] |
| 788 | blanks_after: list[int] = [] |
| 789 | body_stack: list[int] = [] |
| 790 | |
| 791 | for i, line in enumerate(lines): |
| 792 | if line.kind == "open": |
| 793 | body_stack.append(i + 1) |
| 794 | continue |
| 795 | |
| 796 | delta = _brace_delta(line) |
| 797 | if delta < 0 and body_stack: |
| 798 | start = body_stack.pop() |
| 799 | _check_shallow_id(lines, start, i, path, violations, blanks_after) |
| 800 | |
| 801 | return violations, blanks_after |
| 802 | |
| 803 | |
| 804 | def _check_shallow_id( |
no test coverage detected