-
Notifications
You must be signed in to change notification settings - Fork 1.6k
type: ignore[codes] and knot: ignore
#15078
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
Conversation
bce107e to
570f2f8
Compare
b03fb8a to
5259a0f
Compare
|
5259a0f to
7078786
Compare
carljm
left a comment
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.
Sweet!
|
|
||
| ## Empty codes | ||
|
|
||
| An empty codes array suppresses no-diagnostics and is always useless |
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.
Is this something that we should flag, or just let it pass silently?
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.
Nice catch. I updated #15084 to correctly mark the suppression as unused
| if self.cursor.eat_if(char::is_whitespace) { | ||
| self.cursor.eat_while(char::is_whitespace); |
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.
Should we use is_python_whitespace?
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.
Using is_whitespace should be fine because we're in a comment. This also matches the formatter's docstring handling
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