-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Start detecting version-related syntax errors in the parser #16090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 53 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
e871194
add unused Parser::syntax_errors field
ntBre 591063f
add hard-coded python version and detect `match`
ntBre e628e66
make PythonVersion more public, convert SyntaxError in red-knot
ntBre 36ee9cd
process SyntaxErrors in ruff
ntBre 611bda9
pass target version at the very end
ntBre bfb3bb5
pass tests
ntBre a6b8e34
add ruff test case
ntBre 288821d
detect late future imports in the parser
ntBre ed67b01
pass f404 tests
ntBre fbf8765
check if rules are enabled before converting to diagnostics
ntBre 5768f71
add a todo about duplicate diagnostics
ntBre 2ecf3f2
clippy
ntBre ef858bf
update to use ast::PythonVersion and Span
ntBre d817289
remove LateFutureImport detection from the parser
ntBre 6e4b956
tidy up
ntBre 1805a65
clean up after rebase
ntBre cf77087
add ParseOptions::target_version
ntBre 3c67b03
filter syntax errors when parsing, store version on SyntaxError
ntBre 09ccf65
make ParseOptions Clone
ntBre a6bc0db
pass ParseOptions::target_version in the linter
ntBre 49a48f2
pass ParseOptions::target_version in red-knot
ntBre 79e6322
ignore version-related syntax errors when fuzzing
ntBre 12d04b0
Red-knot no longer panics!
AlexWaygood efb9c2a
Fix fuzzing script and fix Rust formatting
AlexWaygood ee30486
Revert "ignore version-related syntax errors when fuzzing"
ntBre c8a22c5
pass check_file_skips_type_checking_when by initializing settings
ntBre 380aaff
fix clippy lint about &impl ToString
ntBre 80be7f7
pass version to new parsed_module call
ntBre 6b69bb5
use LinterSettings::resolve_target_version
ntBre cd02f61
add ok test for match
ntBre cd90966
gate syntax error reporting behind preview
ntBre db77d9e
add docs for SyntaxError
ntBre 1210a2f
use PythonVersion Display
ntBre 8c4cf8c
impl Display instead of separate `message` method
ntBre a2f70cd
remove unused match
ntBre 5a7906d
rename version to minimum_version
ntBre 63e4a5a
mdtest version-related errors in red-knot
ntBre f3e5636
pass existing tests using `match`
ntBre 3b93520
just use InvalidSyntax variant for version errors
ntBre 16f1ae2
use SyntaxError::minimum_version
ntBre 3dbb7f7
delete unused SyntaxErrorKind::as_str
ntBre be1a6fd
SyntaxError -> UnsupportedSyntaxError
ntBre 1714b60
SyntaxErrorKind -> UnsupportedSyntaxErrorKind
ntBre 418dd0f
rename fields and methods too
ntBre d78463c
move target_version out of loop
ntBre c672d22
only mark `match` for diagnostic
ntBre 1a363ab
update is_valid docs
ntBre 8035b13
update as_result and into_result docs too
ntBre bbb4bc4
always include unsupported_syntax_errors
ntBre 18d9b6c
check for unsupported syntax errors in ruff_server
ntBre 9980a6a
pass target_version to check_path
ntBre 45c3b67
revert red-knot changes
ntBre 8b14483
new -> added
ntBre 76d507b
add checkpoint for unsupported_syntax_errors
ntBre 5711091
chain diagnostics
ntBre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect we're now resolving the
target_version
multiple times. Once here and then somewhere insidecheck_path
? I guess that's probably fine but I wonder how much work it would be to avoid it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh good catch. I was able to remove the resolution in
check_path
by passing the version to it everywhere. The other three resolutions in the linter are inadd_noqa_to_path
,lint_only
, andlint_fix
and right beforeparse_unchecked
calls, so I think those are needed.This is probably a separate issue, but do we need to re-parse (and re-resolve) in
add_noqa_to_path
? I guess it gets called before we know what else we're doing with the files.