Avoid caching files with unsupported syntax errors#16425
Merged
MichaReiser merged 3 commits intomainfrom Feb 28, 2025
Merged
Conversation
Contributor
|
dhruvmanila
reviewed
Feb 28, 2025
| &directives, | ||
| ), | ||
| has_syntax_error: !parsed.is_valid(), | ||
| has_syntax_error: !parsed.is_valid() || !parsed.unsupported_syntax_errors().is_empty(), |
Member
There was a problem hiding this comment.
I wonder if we should have a separate version of is_valid method that checks both ParseError and UnsupportedSyntaxError which can then be used here. I'm not sure what to name the method though as both are syntax errors at the end 😅
dhruvmanila
approved these changes
Feb 28, 2025
MichaReiser
approved these changes
Feb 28, 2025
Member
MichaReiser
left a comment
There was a problem hiding this comment.
This looks great. I did a quick check that we aren't using the LintResult::has_syntax_errors for anything other than caching.
Can we update the documentation on LinterResult to make it explicit that this includes both syntax and unsupported syntax errors.
dcreager
added a commit
that referenced
this pull request
Feb 28, 2025
* main: [red-knot] Switch to a handwritten parser for mdtest error assertions (#16422) [red-knot] Disallow more invalid type expressions (#16427) Bump version to Ruff 0.9.9 (#16434) Check `LinterSettings::preview` for version-related syntax errors (#16429) Avoid caching files with unsupported syntax errors (#16425) Prioritize "bug" label for changelog sections (#16433) [`flake8-copyright`] Add links to applicable options (`CPY001`) (#16421) Fix string-length limit in documentation for PYI054 (#16432) Show version-related syntax errors in the playground (#16419) Allow passing `ParseOptions` to inline tests (#16357) Bump version to 0.9.8 (#16414) [red-knot] Ignore surrounding whitespace when looking for `<!-- snapshot-diagnostics -->` directives in mdtests (#16380) Notify users for invalid client settings (#16361) Avoid indexing the project if `configurationPreference` is `editorOnly` (#16381)
dcreager
added a commit
that referenced
this pull request
Feb 28, 2025
* dcreager/alist-type: Remove unneeded shear override Update property test CI Move alist into red_knot_python_semantic [red-knot] Switch to a handwritten parser for mdtest error assertions (#16422) [red-knot] Disallow more invalid type expressions (#16427) Bump version to Ruff 0.9.9 (#16434) Check `LinterSettings::preview` for version-related syntax errors (#16429) Avoid caching files with unsupported syntax errors (#16425) Prioritize "bug" label for changelog sections (#16433) [`flake8-copyright`] Add links to applicable options (`CPY001`) (#16421) Fix string-length limit in documentation for PYI054 (#16432) Show version-related syntax errors in the playground (#16419) Allow passing `ParseOptions` to inline tests (#16357) Bump version to 0.9.8 (#16414) [red-knot] Ignore surrounding whitespace when looking for `<!-- snapshot-diagnostics -->` directives in mdtests (#16380) Notify users for invalid client settings (#16361) Avoid indexing the project if `configurationPreference` is `editorOnly` (#16381)
ntBre
added a commit
that referenced
this pull request
Feb 28, 2025
…ors` 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.
ntBre
added a commit
that referenced
this pull request
Feb 28, 2025
…ors` 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.
ntBre
added a commit
that referenced
this pull request
Mar 4, 2025
…tax_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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR includes the new
Parsed::unsupported_syntax_errorsfield when determining if aLinterResulthas a syntax error. This prevents caching files with version-related syntax errors, which led to these errors only being reported on the first ruff run.Fixes #16417 in combination with #16419, modulo the discussion split off into #16418.
Test Plan
New CLI test that reported no errors in the second case on
main(see the first commit).