mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Document LinterResult::has_syntax_error
and add Parsed::has_no_syntax_errors
(#16443)
Summary -- This is a follow up addressing the comments on #16425. As @dhruvmanila pointed out, the naming is a bit tricky. I went with `has_no_errors` to try to differentiate it from `is_valid`. It actually ends up negated in most uses, so it would be more convenient to have `has_any_errors` or `has_errors`, but I thought it would sound too much like the opposite of `is_valid` in that case. I'm definitely open to suggestions here. Test Plan -- Existing tests.
This commit is contained in:
parent
a3ae76edc0
commit
37fbe58b13
6 changed files with 50 additions and 26 deletions
|
@ -141,7 +141,7 @@ pub(crate) fn test_contents<'a>(
|
|||
target_version,
|
||||
);
|
||||
|
||||
let source_has_errors = !parsed.is_valid();
|
||||
let source_has_errors = parsed.has_invalid_syntax();
|
||||
|
||||
// Detect fixes that don't converge after multiple iterations.
|
||||
let mut iterations = 0;
|
||||
|
@ -207,7 +207,7 @@ pub(crate) fn test_contents<'a>(
|
|||
target_version,
|
||||
);
|
||||
|
||||
if !parsed.is_valid() && !source_has_errors {
|
||||
if parsed.has_invalid_syntax() && !source_has_errors {
|
||||
// Previous fix introduced a syntax error, abort
|
||||
let fixes = print_diagnostics(diagnostics, path, source_kind);
|
||||
let syntax_errors =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue