Extract error diagnostics from a pyright JSON report. Args: report: The parsed ``--outputjson`` document. Returns: A mapping from a stable diagnostic key (file, line, character, message) to a formatted, human-readable display line.
(report: dict)
| 336 | |
| 337 | |
| 338 | def _pyright_errors(report: dict) -> dict[tuple[str, int, int, str], str]: |
| 339 | """Extract error diagnostics from a pyright JSON report. |
| 340 | |
| 341 | Args: |
| 342 | report: The parsed ``--outputjson`` document. |
| 343 | |
| 344 | Returns: |
| 345 | A mapping from a stable diagnostic key (file, line, character, message) to a |
| 346 | formatted, human-readable display line. |
| 347 | """ |
| 348 | errors: dict[tuple[str, int, int, str], str] = {} |
| 349 | for diagnostic in report.get("generalDiagnostics", []): |
| 350 | if diagnostic.get("severity") != "error": |
| 351 | continue |
| 352 | start = diagnostic.get("range", {}).get("start", {}) |
| 353 | if "line" not in start or "character" not in start: |
| 354 | continue |
| 355 | key = ( |
| 356 | diagnostic["file"], |
| 357 | start["line"], |
| 358 | start["character"], |
| 359 | diagnostic["message"], |
| 360 | ) |
| 361 | errors[key] = ( |
| 362 | f"{diagnostic['file']}:{start['line'] + 1}:{start['character'] + 1}" |
| 363 | f" - error: {diagnostic['message']}" |
| 364 | ) |
| 365 | return errors |
| 366 | |
| 367 | |
| 368 | def _resolve_and_check( |
no test coverage detected