Convert checker violations (dict or CheckerResults) to CheckerResults format. Args: violations: Either a CheckerResults object or legacy dict format Returns: CheckerResults object
(violations: Any)
| 649 | |
| 650 | |
| 651 | def _convert_violations_to_results(violations: Any) -> CheckerResults: |
| 652 | """Convert checker violations (dict or CheckerResults) to CheckerResults format. |
| 653 | |
| 654 | Args: |
| 655 | violations: Either a CheckerResults object or legacy dict format |
| 656 | |
| 657 | Returns: |
| 658 | CheckerResults object |
| 659 | """ |
| 660 | if isinstance(violations, CheckerResults): |
| 661 | return violations |
| 662 | |
| 663 | # Legacy dict format conversion |
| 664 | results = CheckerResults() |
| 665 | for file_path, violation_list in violations.items(): |
| 666 | if isinstance(violation_list, list): |
| 667 | for item in violation_list: # type: ignore[reportUnknownVariableType] |
| 668 | converted = _legacy_violation_item_to_line_content(item) |
| 669 | results.add_violation( |
| 670 | file_path, converted.line_number, converted.message |
| 671 | ) |
| 672 | elif isinstance(violation_list, str): |
| 673 | results.add_violation(file_path, 0, violation_list) |
| 674 | |
| 675 | return results |
| 676 | |
| 677 | |
| 678 | def _collect_violations_from_checkers( |
no test coverage detected