Move Azure output format to the new diagnostic format#19129
Closed
Move Azure output format to the new diagnostic format#19129
Conversation
Contributor
Author
|
Not sure about the labels here 😆 it should be |
Contributor
|
ntBre
commented
Jul 3, 2025
Contributor
|
Contributor
Author
|
I started working on JSON output after this, and I think we may end up needing the |
ntBre
added a commit
that referenced
this pull request
Jul 11, 2025
…19133) ## Summary This was originally stacked on #19129, but some of the changes I made for JSON also impacted the Azure format, so I went ahead and combined them. The main changes here are: - Implementing `FileResolver` for Ruff's `EmitterContext` - Adding `FileResolver::notebook_index` and `FileResolver::is_notebook` methods - Adding a `DisplayDiagnostics` (with an "s") type for rendering a group of diagnostics at once - Adding `Azure`, `Json`, and `JsonLines` as new `DiagnosticFormat`s I tried a couple of alternatives to the `FileResolver::notebook` methods like passing down the `NotebookIndex` separately and trying to reparse a `Notebook` from Ruff's `SourceFile`. The latter seemed promising, but the `SourceFile` only stores the concatenated plain text of the notebook, not the re-parsable JSON. I guess the current version is just a variation on passing the `NotebookIndex`, but at least we can reuse the existing `resolver` argument. I think a lot of this can be cleaned up once Ruff has its own actual file resolver. As suggested, I also tried deleting the corresponding `Emitter` files in `ruff_linter`, but it doesn't look like git was able to follow this as a rename. It did, however, track that the tests were moved, so the snapshots should be easy to review. ## Test Plan Existing Ruff tests ported to tests in `ruff_db`. I think some other existing ruff tests also cover parts of this refactor. --------- Co-authored-by: Micha Reiser <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a dummy
FileResolverto Ruff to enable using theruff_db::Diagnosticrendering code and ports one of the simplest output formats (azure) to aruff_db::DiagnosticFormat. This also made it very easy to add support for this output format to ty.I think this will eventually allow us to rework, or even remove, the
Emitterinfrastructure in Ruff, but my plan for now is just to port the internals of eachEmitter.We didn't have any tests for this, but I removed this check:
ruff/crates/ruff_linter/src/message/azure.rs
Lines 22 to 28 in 333191b
because the line numbers in notebooks look sensible to me. This matches the current behavior of ty too.
Test Plan
Existing Ruff tests and a new ty CLI test