ruff/crates
Brent Westbrook b324ae1be3
Hide empty snippets for full-file diagnostics (#19653)
Summary
--

This is the other commit I wanted to spin off from #19415, currently
stacked on #19644.

This PR suppresses blank snippets for empty ranges at the very beginning
of a file, and for empty ranges in non-existent files. Ruff includes
empty ranges for IO errors, for example.


f4e93b6335/crates/ruff_linter/src/message/text.rs (L100-L110)

The diagnostics now look like this (new snapshot test):

```
error[test-diagnostic]: main diagnostic message
--> example.py:1:1                             
```

Instead of [^*]

```
error[test-diagnostic]: main diagnostic message
--> example.py:1:1
 |
 |
```

Test Plan
--

A new `ruff_db` test showing the expected output format

[^*]: This doesn't correspond precisely to the example in the PR because
of some details of the diagnostic builder helper methods in `ruff_db`,
but you can see another example in the current version of the summary in
#19415.
2025-08-05 11:20:31 -04:00
..
ruff Allow hiding the diagnostic severity in ruff_db (#19644) 2025-08-05 09:56:18 -04:00
ruff_annotate_snippets Hide empty snippets for full-file diagnostics (#19653) 2025-08-05 11:20:31 -04:00
ruff_benchmark [ty] Remove special casing for tuple addition (#19636) 2025-07-30 16:25:42 +00:00
ruff_cache
ruff_db Hide empty snippets for full-file diagnostics (#19653) 2025-08-05 11:20:31 -04:00
ruff_dev Auto-generate environment variable references for ty (#19205) 2025-07-08 10:48:31 -04:00
ruff_diagnostics [ty] Implement diagnostic caching (#19605) 2025-07-30 11:04:34 +01:00
ruff_formatter
ruff_graph [ty] Remove KnownModule::is_enum (#19681) 2025-08-01 10:31:12 +02:00
ruff_index Update Rust toolchain to 1.88 and MSRV to 1.86 (#19011) 2025-06-28 20:24:00 +02:00
ruff_linter Hide empty snippets for full-file diagnostics (#19653) 2025-08-05 11:20:31 -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 Disallow implicit concatenation of t-strings and other string types (#19485) 2025-07-27 12:41:03 +00:00
ruff_python_ast_integration_tests Disallow implicit concatenation of t-strings and other string types (#19485) 2025-07-27 12:41:03 +00:00
ruff_python_codegen Disallow implicit concatenation of t-strings and other string types (#19485) 2025-07-27 12:41:03 +00:00
ruff_python_formatter Disallow implicit concatenation of t-strings and other string types (#19485) 2025-07-27 12:41:03 +00:00
ruff_python_index
ruff_python_literal
ruff_python_parser Disallow implicit concatenation of t-strings and other string types (#19485) 2025-07-27 12:41:03 +00:00
ruff_python_semantic [ty] Make Module a Salsa ingredient 2025-07-23 09:46:40 -04:00
ruff_python_stdlib
ruff_python_trivia
ruff_python_trivia_integration_tests
ruff_server [ty] Implement long-polling for workspace diagnsotics (#19670) 2025-08-04 10:26:38 +00:00
ruff_source_file [ty] Implement diagnostic caching (#19605) 2025-07-30 11:04:34 +01: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 Allow hiding the diagnostic severity in ruff_db (#19644) 2025-08-05 09:56:18 -04:00
ruff_workspace Add support for specifying minimum dots in detected string imports (#19538) 2025-07-24 15:48:23 -04:00
ty [ty] Return Option<TupleType> from infer_tuple_type_expression (#19735) 2025-08-04 13:48:19 +01:00
ty_ide [ty] Fix attribute access on TypedDicts (#19758) 2025-08-05 13:59:10 +02:00
ty_project [ty] Implement streaming for workspace diagnostics (#19657) 2025-08-04 09:34:29 +00:00
ty_python_semantic [ty] Fix more false positives related to Generic or Protocol being subscripted with a ParamSpec or TypeVarTuple (#19764) 2025-08-05 15:45:56 +01:00
ty_server Use fixed hash width for ty_server diagnostics (#19766) 2025-08-05 10:55:17 -04:00
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] Improve debuggability of protocol types (#19662) 2025-08-01 15:16:13 +01:00
ty_wasm [ty] Support stdlib files in playground (#19557) 2025-07-26 19:33:38 +01:00