Fix E30X panics on blank lines with trailing white spaces#9907
Merged
MichaReiser merged 2 commits intoastral-sh:mainfrom Feb 9, 2024
Merged
Fix E30X panics on blank lines with trailing white spaces#9907MichaReiser merged 2 commits intoastral-sh:mainfrom
E30X panics on blank lines with trailing white spaces#9907MichaReiser merged 2 commits intoastral-sh:mainfrom
Conversation
47e801b to
579dfb5
Compare
Contributor
Member
|
Thanks for looking into the panic. I'm reluctant to just remove the assertion without better understanding the reason why it is incorrect (I added it to guarantee it's only called on two directly following lines). Would you mind adding an example explaining why the two ranges don't end and start at the same position to the PR summary? |
Contributor
Author
|
@MichaReiser This happens because of the whitespaces, I added an explanation to the PR summary. |
MichaReiser
approved these changes
Feb 9, 2024
Member
|
Thanks for the explanation. That makes sense |
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
closes #9906
The #9906 issue is triggered by blank lines with trailing white spaces. The trailing spaces cause the
assert_eq!that was added in this discussion to fail.This PR removes the
assert_eq!.Test Plan
I tested the change on the python files provided in #9906 (on top of cargo test).
I also added a few fixtures with blank lines with trailing white spaces.
Issue example/explaination
The issue is triggered by blank lines with trailing white spaces.
For example, by creating a blank file with
echo "\n \n" >> temp.py, we get the snippet given in the issue:Running ruff on this, we get the following tokens:
We can see that the end of the first token range's end and the second token range's start do not match because of the 5 spaces.