mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Add noqa_row
to diagnostics JSON format (#3228)
In ruff-lsp (https://github.com/charliermarsh/ruff-lsp/pull/76) we want to add a "Disable \<rule\> for this line" quickfix. However, finding the correct line into which the `noqa` comment should be inserted is non-trivial (multi-line strings for example). Ruff already has this info, so expose it in the JSON output for use by ruff-lsp.
This commit is contained in:
parent
cd9fbeb560
commit
33c31cda27
5 changed files with 19 additions and 3 deletions
|
@ -114,6 +114,7 @@ pub fn run(
|
|||
),
|
||||
format!("{}", path.display()),
|
||||
None,
|
||||
1,
|
||||
)])
|
||||
} else {
|
||||
Diagnostics::default()
|
||||
|
|
|
@ -50,6 +50,7 @@ struct ExpandedMessage<'a> {
|
|||
location: Location,
|
||||
end_location: Location,
|
||||
filename: &'a str,
|
||||
noqa_row: usize,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
|
@ -197,6 +198,7 @@ impl Printer {
|
|||
location: message.location,
|
||||
end_location: message.end_location,
|
||||
filename: &message.filename,
|
||||
noqa_row: message.noqa_row,
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
)?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue