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
ruff_benchmark [ty] Add support for @warnings.deprecated (#19376) 2025-07-18 23:50:29 +00:00
ruff_cache
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
ruff_graph [ty] Track open files in the server (#19264) 2025-07-18 19:33:35 +05:30
ruff_index
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
ruff_options_metadata
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
ruff_python_codegen
ruff_python_formatter Update pre-commit dependencies (#19162) 2025-07-07 04:07:44 +00:00
ruff_python_index
ruff_python_literal
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
ruff_python_trivia
ruff_python_trivia_integration_tests
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
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