From b2d1fcf7b259359312d43c3e4f8a4716656701b6 Mon Sep 17 00:00:00 2001 From: Tony Lykke Date: Wed, 18 Oct 2023 18:46:59 -0400 Subject: [PATCH] add instructions on line-level suppression to file-level suppression warning (#8052) ## Summary In #6157 a warning was introduced when users use `ruff: noqa` suppression in-line instead of at the file-level. I had this trigger today after forgetting about it, and the warning is an excellent improvement. I knew immediately what the issue was because I raised it previously, but on reading the warning I'm not sure it would be so obvious to all users. This PR extends the error with a short sentence explaining that line-level suppression should omit the `ruff:` prefix. ## Test Plan Not sure it's necessary for such a trivial change :) --- crates/ruff_linter/src/noqa.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ruff_linter/src/noqa.rs b/crates/ruff_linter/src/noqa.rs index b53976dae0..e98f33bcf7 100644 --- a/crates/ruff_linter/src/noqa.rs +++ b/crates/ruff_linter/src/noqa.rs @@ -253,7 +253,7 @@ impl FileExemption { #[allow(deprecated)] let line = locator.compute_line_index(range.start()); let path_display = relativize_path(path); - warn!("Unexpected `# ruff: noqa` directive at {path_display}:{line}. File-level suppression comments must appear on their own line."); + warn!("Unexpected `# ruff: noqa` directive at {path_display}:{line}. File-level suppression comments must appear on their own line. For line-level suppression, omit the `ruff:` prefix."); continue; }