mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 21:34:57 +00:00
Rename Diagnostic::syntax_error
methods, separate Ord
implementation (#19179)
## Summary This PR addresses some additional feedback on #19053: - Renaming the `syntax_error` methods to `invalid_syntax` to match the lint id - Moving the standalone `diagnostic_from_violation` function to `Violation::into_diagnostic` - Removing the `Ord` and `PartialOrd` implementations from `Diagnostic` in favor of `Diagnostic::start_ordering` ## Test Plan Existing tests ## Additional Follow-ups Besides these, I also put the following comments on my todo list, but they seemed like they might be big enough to have their own PRs: - [Use `LintId::IOError` for IO errors](https://github.com/astral-sh/ruff/pull/19053#discussion_r2189425922) - [Move `Fix` and `Edit`](https://github.com/astral-sh/ruff/pull/19053#discussion_r2189448647) - [Avoid so many unwraps](https://github.com/astral-sh/ruff/pull/19053#discussion_r2189465980)
This commit is contained in:
parent
738692baff
commit
2643dc5b7a
19 changed files with 91 additions and 120 deletions
|
@ -292,7 +292,7 @@ Either ensure you always emit a fix or change `Violation::FIX_AVAILABILITY` to e
|
|||
.chain(parsed.errors().iter().map(|parse_error| {
|
||||
create_syntax_error_diagnostic(source_code.clone(), &parse_error.error, parse_error)
|
||||
}))
|
||||
.sorted()
|
||||
.sorted_by(Diagnostic::ruff_start_ordering)
|
||||
.collect();
|
||||
(messages, transformed)
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ fn print_syntax_errors(errors: &[ParseError], path: &Path, source: &SourceKind)
|
|||
|
||||
/// Print the lint diagnostics in `diagnostics`.
|
||||
fn print_diagnostics(mut diagnostics: Vec<Diagnostic>, path: &Path, source: &SourceKind) -> String {
|
||||
diagnostics.retain(|msg| !msg.is_syntax_error());
|
||||
diagnostics.retain(|msg| !msg.is_invalid_syntax());
|
||||
|
||||
if let Some(notebook) = source.as_ipy_notebook() {
|
||||
print_jupyter_messages(&diagnostics, path, notebook)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue