mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
![]() Summary -- I thought that emitting multiple diagnostics at once would be difficult to port to a diagnostic construction model closer to ty's `InferContext::report_lint`, so as a first step toward that, this PR removes `Checker::report_diagnostics`. In many cases I was able to do some related refactoring to avoid allocating a `Vec<Diagnostic>` at all, often by adding a `Checker` field to a `Visitor` or by passing a `Checker` instead of a `&mut Vec<Diagnostic>`. In other cases, I had to fall back on something like ```rust for diagnostic in diagnostics { checker.report_diagnostic(diagnostic); } ``` which I guess is a bit worse than the `extend` call in `report_diagnostics`, but hopefully it won't make too much of a difference. I'm still not quite sure what to do with the remaining loop cases. The two main use cases for collecting a sequence of diagnostics before emitting any of them are: 1. Applying a single `Fix` to a group of diagnostics 2. Avoiding an earlier diagnostic if something goes wrong later I was hoping we could get away with just a `DiagnosticGuard` that reported a `Diagnostic` on drop, but I guess we will still need a `DiagnosticGuardBuilder` that can be collected in these cases and produce a `DiagnosticGuard` once we know we actually want the diagnostics. Test Plan -- Existing tests |
||
---|---|---|
.. | ||
ruff | ||
ruff_annotate_snippets | ||
ruff_benchmark | ||
ruff_cache | ||
ruff_db | ||
ruff_dev | ||
ruff_diagnostics | ||
ruff_formatter | ||
ruff_graph | ||
ruff_index | ||
ruff_linter | ||
ruff_macros | ||
ruff_notebook | ||
ruff_options_metadata | ||
ruff_python_ast | ||
ruff_python_ast_integration_tests | ||
ruff_python_codegen | ||
ruff_python_formatter | ||
ruff_python_index | ||
ruff_python_literal | ||
ruff_python_parser | ||
ruff_python_resolver | ||
ruff_python_semantic | ||
ruff_python_stdlib | ||
ruff_python_trivia | ||
ruff_python_trivia_integration_tests | ||
ruff_server | ||
ruff_source_file | ||
ruff_text_size | ||
ruff_wasm | ||
ruff_workspace | ||
ty | ||
ty_ide | ||
ty_project | ||
ty_python_semantic | ||
ty_server | ||
ty_test | ||
ty_vendored | ||
ty_wasm |