Refactor tab-indentation as a token-based rule#7435
Merged
dhruvmanila merged 3 commits intomainfrom Sep 16, 2023
Merged
Conversation
Member
Author
|
Current dependencies on/for this PR: This comment was auto-generated by Graphite. |
charliermarsh
approved these changes
Sep 16, 2023
| line_start: TextSize, | ||
| ) { | ||
| let indent = leading_indentation(locator.after(line_start)); | ||
| if indent.find('\t').is_some() { |
Member
There was a problem hiding this comment.
We could probably do the leading_indentation and tab find in one pass, via take_while and find?
Member
Author
There was a problem hiding this comment.
I tried this but we need the indent length for the diagnostic range:
TextRange::at(line_start, indent.text_len())
Contributor
PR Check ResultsEcosystem✅ ecosystem check detected no changes. |
CodSpeed Performance ReportMerging #7435 will not alter performanceComparing Summary
|
1245af9 to
c025c41
Compare
auto-merge was automatically disabled
September 16, 2023 20:16
Pull request was closed
dhruvmanila
added a commit
that referenced
this pull request
Sep 18, 2023
## Summary This is a follow-up PR for #7435 to remove the now unused triple-quoted string ranges from the indexer.
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 updates the
W191(tab-indentation) rule from a line-based to atoken-based rule.
Earlier, the rule used the
triple_quoted_string_rangesfrom the indexer toskip over any lines inside a triple-quoted string. This was the only use of
the ranges. These ranges were extracted through the tokens, so instead we can
directly use the newline tokens to perform the check.
This would also mean that we can remove the
triple_quoted_string_rangesfromthe indexer but I'll hold that off until we have a better idea on #7326 but I
don't think it would be a problem to remove it.
This will also fix #7379 once PEP 701 changes are merged.
Test Plan
cargo test