Sorting is only safe when every logical line is a single physical 'prop' line with no inline braces or brackets. The tokenizer already absorbs multi-line props into one LogicalLine; any line with more than one physical source line is therefore a multi-line value and skipped.
(run: list[LogicalLine])
| 467 | |
| 468 | |
| 469 | def is_run_safe(run: list[LogicalLine]) -> bool: |
| 470 | """Sorting is only safe when every logical line is a single physical |
| 471 | 'prop' line with no inline braces or brackets. The tokenizer already |
| 472 | absorbs multi-line props into one LogicalLine; any line with more than |
| 473 | one physical source line is therefore a multi-line value and skipped.""" |
| 474 | for line in run: |
| 475 | if line.kind != "prop": |
| 476 | return False |
| 477 | if len(line.raws) != 1: |
| 478 | return False |
| 479 | sanitized = _strip_strings_and_comments(line.raws[0]) |
| 480 | # Reject inline nested blocks or collection literals on the value. |
| 481 | if any(ch in sanitized for ch in "{}[]"): |
| 482 | return False |
| 483 | return True |
| 484 | |
| 485 | |
| 486 | # --------------------------------------------------------------------------- |
no test coverage detected