ruff/crates
Brent Westbrook fd335eb8b7
Move fix suggestion to subdiagnostic (#19464)
Summary
--

This PR tweaks Ruff's internal usage of the new diagnostic model to more
closely
match the intended use, as I understand it. Specifically, it moves the
fix/help
suggestion from the primary annotation's message to a subdiagnostic. In
turn, it
adds the secondary/noqa code as the new primary annotation message. As
shown in
the new `ruff_db` tests, this more closely mirrors Ruff's current
diagnostic
output.

I also added `Severity::Help` to render the fix suggestion with a
`help:` prefix
instead of `info:`.

These changes don't have any external impact now but should help a bit
with #19415.

Test Plan
--

New full output format tests in `ruff_db`

Rendered Diagnostics
--

Full diagnostic output from `annotate-snippets` in this PR:

``` 
error[unused-import]: `os` imported but unused
  --> fib.py:1:8
   |
 1 | import os
   |        ^^
   |
 help: Remove unused import: `os`
```

Current Ruff output for the same code:

```
fib.py:1:8: F401 [*] `os` imported but unused
  |
1 | import os
  |        ^^ F401
  |
  = help: Remove unused import: `os`
```

Proposed final output after #19415:

``` 
F401 [*] `os` imported but unused
  --> fib.py:1:8
   |
 1 | import os
   |        ^^
   |
 help: Remove unused import: `os`
```

These are slightly updated from
https://github.com/astral-sh/ruff/pull/19464#issuecomment-3097377634
below to remove the extra noqa codes in the primary annotation messages
for the first and third cases.
2025-07-22 10:03:58 -04:00
..
ruff Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -04:00
ruff_annotate_snippets Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
ruff_benchmark [ty] Add support for @warnings.deprecated (#19376) 2025-07-18 23:50:29 +00:00
ruff_cache Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_db Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -04:00
ruff_dev Auto-generate environment variable references for ty (#19205) 2025-07-08 10:48:31 -04:00
ruff_diagnostics Combine OldDiagnostic and Diagnostic (#19053) 2025-07-03 13:01:09 -04:00
ruff_formatter Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_graph [ty] Track open files in the server (#19264) 2025-07-18 19:33:35 +05:30
ruff_index Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
ruff_linter Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -04:00
ruff_macros [ty] Merge ty_macros into ruff_macros (#19229) 2025-07-09 11:28:21 +00:00
ruff_notebook Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_options_metadata [ty] Document configuration schema (#17950) 2025-05-09 10:47:45 +02:00
ruff_python_ast [ty] Use an interval map for scopes by expression (#19025) 2025-07-14 13:50:58 +02:00
ruff_python_ast_integration_tests [ty] AST garbage collection (#18482) 2025-06-13 08:40:11 -04:00
ruff_python_codegen Fix f-string interpolation escaping (#18882) 2025-06-25 10:04:15 +02:00
ruff_python_formatter Update pre-commit dependencies (#19162) 2025-07-07 04:07:44 +00:00
ruff_python_index Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_literal Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_parser Fix unreachable panic in parser (#19183) 2025-07-20 22:04:14 +00:00
ruff_python_semantic [flake8-return] Fix false-positive for variables used inside nested functions in RET504 (#18433) 2025-07-10 16:10:22 -04:00
ruff_python_stdlib Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_python_trivia Treat ty: comments as pragma comments (#18532) 2025-06-07 16:02:43 +02:00
ruff_python_trivia_integration_tests Switch to Rust 2024 edition (#18129) 2025-05-16 13:25:28 +02:00
ruff_server Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -04:00
ruff_source_file Move Pylint rendering to ruff_db (#19340) 2025-07-15 10:14:49 -04:00
ruff_text_size [ty] Add environment variable to dump Salsa memory usage stats (#18928) 2025-06-26 21:27:51 +00:00
ruff_wasm Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -04:00
ruff_workspace [flake8-type-checking, pyupgrade, ruff] Add from __future__ import annotations when it would allow new fixes (TC001, TC002, TC003, UP037, RUF013) (#19100) 2025-07-16 08:50:52 -04:00
ty [ty] Add warning for unknown TY_MEMORY_REPORT value (#19465) 2025-07-21 14:29:24 +00:00
ty_ide Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -04:00
ty_project Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -04:00
ty_python_semantic Move fix suggestion to subdiagnostic (#19464) 2025-07-22 10:03:58 -04:00
ty_server [ty] Track open files in the server (#19264) 2025-07-18 19:33:35 +05:30
ty_static [ty] Merge ty_macros into ruff_macros (#19229) 2025-07-09 11:28:21 +00:00
ty_test [ty] Track open files in the server (#19264) 2025-07-18 19:33:35 +05:30
ty_vendored [ty] Sync vendored typeshed stubs (#19461) 2025-07-21 14:01:42 +01:00
ty_wasm [ty] Add goto definition to playground (#19425) 2025-07-19 15:44:44 +02:00