type: ignore[codes] and knot: ignore#15078
Merged
MichaReiser merged 1 commit intomainfrom Dec 23, 2024
Merged
Conversation
bce107e to
570f2f8
Compare
b03fb8a to
5259a0f
Compare
Contributor
|
5259a0f to
7078786
Compare
carljm
approved these changes
Dec 22, 2024
|
|
||
| ## Empty codes | ||
|
|
||
| An empty codes array suppresses no-diagnostics and is always useless |
Contributor
There was a problem hiding this comment.
Is this something that we should flag, or just let it pass silently?
Member
Author
There was a problem hiding this comment.
Nice catch. I updated #15084 to correctly mark the suppression as unused
dhruvmanila
reviewed
Dec 23, 2024
Comment on lines
+294
to
+295
| if self.cursor.eat_if(char::is_whitespace) { | ||
| self.cursor.eat_while(char::is_whitespace); |
Member
There was a problem hiding this comment.
Should we use is_python_whitespace?
Member
Author
There was a problem hiding this comment.
Using is_whitespace should be fine because we're in a comment. This also matches the formatter's docstring handling
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 adds support for parsing
type: ignorecomments that have an optional codes segment, e.g.type: ignore[a, b, c]. It also introduces the newknot: ignore[codes]suppression comment.The logic is split into two parts:
# type: ignorecommentSuppressionsfor each comment.I've decided to "flatten" ignore comments with multiple codes into multiple
Suppressioninstances because I think it will simplifythe tracking of unused suppressions and it avoids a nested vector for the lint ids in
Suppression.Test Plan
Added md test