ruff_db: a small tweak to remove empty message case

In a subsequent commit, we're going to start using `annotate-snippets`'s
functionality for diagnostic IDs in the rendering. As part of doing
that, I wanted to remove this special casing of an empty message. I did
that independently to see what, if anything, would change. (The changes
look fine to me. They'll be tweaked again in the next commit along with
a bunch of others.)
This commit is contained in:
Andrew Gallant
2025-05-09 11:29:20 -04:00
committed by Andrew Gallant
parent 2c4cbb6e29
commit 244ea27d5f
5 changed files with 12 additions and 15 deletions

View File

@@ -197,9 +197,7 @@ impl<'a> ResolvedDiagnostic<'a> {
ResolvedAnnotation::new(path, &diagnostic_source, ann)
})
.collect();
let message = if diag.inner.message.as_str().is_empty() {
diag.inner.id.as_concise_str().to_string()
} else {
let message =
// TODO: See the comment on `Renderable::id` for
// a plausible better idea than smushing the ID
// into the diagnostic message.
@@ -207,8 +205,7 @@ impl<'a> ResolvedDiagnostic<'a> {
"{id}: {message}",
id = diag.inner.id.as_concise_str(),
message = diag.inner.message.as_str(),
)
};
);
ResolvedDiagnostic {
severity: diag.inner.severity,
message,

View File

@@ -14,7 +14,7 @@ fn test_run_in_sub_directory() -> anyhow::Result<()> {
success: false
exit_code: 1
----- stdout -----
error: invalid-syntax
error: invalid-syntax:
--> <temp_dir>/test.py:1:2
|
1 | ~
@@ -35,7 +35,7 @@ fn test_include_hidden_files_by_default() -> anyhow::Result<()> {
success: false
exit_code: 1
----- stdout -----
error: invalid-syntax
error: invalid-syntax:
--> .test.py:1:2
|
1 | ~
@@ -68,7 +68,7 @@ fn test_respect_ignore_files() -> anyhow::Result<()> {
success: false
exit_code: 1
----- stdout -----
error: invalid-syntax
error: invalid-syntax:
--> test.py:1:2
|
1 | ~
@@ -86,7 +86,7 @@ fn test_respect_ignore_files() -> anyhow::Result<()> {
success: false
exit_code: 1
----- stdout -----
error: invalid-syntax
error: invalid-syntax:
--> test.py:1:2
|
1 | ~
@@ -104,7 +104,7 @@ fn test_respect_ignore_files() -> anyhow::Result<()> {
success: false
exit_code: 1
----- stdout -----
error: invalid-syntax
error: invalid-syntax:
--> test.py:1:2
|
1 | ~
@@ -637,7 +637,7 @@ fn configuration_unknown_rules() -> anyhow::Result<()> {
success: true
exit_code: 0
----- stdout -----
warning: unknown-rule
warning: unknown-rule:
--> pyproject.toml:3:1
|
2 | [tool.ty.rules]

View File

@@ -345,7 +345,7 @@ info: `lint:duplicate-base` is enabled by default
```
```
info: unused-ignore-comment
info: unused-ignore-comment:
--> src/mdtest_snippet.py:72:9
|
70 | A,
@@ -388,7 +388,7 @@ info: `lint:duplicate-base` is enabled by default
```
```
info: unused-ignore-comment
info: unused-ignore-comment:
--> src/mdtest_snippet.py:81:13
|
79 | ):

View File

@@ -32,7 +32,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/diagnostics/semantic_syn
# Diagnostics
```
error: invalid-syntax
error: invalid-syntax:
--> src/mdtest_snippet.py:6:19
|
4 | async def f():

View File

@@ -20,7 +20,7 @@ mdtest path: crates/ty_python_semantic/resources/mdtest/diagnostics/version_rela
# Diagnostics
```
error: invalid-syntax
error: invalid-syntax:
--> src/mdtest_snippet.py:1:1
|
1 | match 2: # error: 1 [invalid-syntax] "Cannot use `match` statement on Python 3.9 (syntax was added in Python 3.10)"