mirror of
https://github.com/astral-sh/ruff.git
synced 2026-10-28 19:00:26 +08:00
Summary -- This addresses the suggestion from [#29635]. `DisplayDiagnosticConfig` previously determined the `DiagnosticFormat` for diagnostics coming from both Ruff and ty, which meant that it had to have a shared enum between the two, despite each program supporting a different subset of the available formats. This PR eliminates the shared `DiagnosticFormat` and dispatch through `DisplayDiagnostics`, leaving Ruff and ty to construct `Renderer`s directly and do their own dispatch on the output formats they actually support. This will be especially helpful in #29635, where we want to provide slightly different arguments to each new `SarifRenderer`. The `Renderer` trait itself isn't strictly necessary, but it made the calls on the Ruff side a lot neater since the trait provides a default `write` method based on the required `render` method. Codex also threw in a default `display` method that helps in a couple of places too. Test Plan -- Existing tests [#29635]: https://github.com/astral-sh/ruff/pull/29635#discussion_r4352505588