-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[
ruff
] Fix panic in unused # noqa
removal with multi-byte space (…
…`RUF100`) (#10682) ## Summary Currently, [this line](https://github.com/astral-sh/ruff/blob/716688d44ecda5d4648b7a31556bb77afe6cbbc6/crates/ruff_linter/src/fix/edits.rs#L101) assumes that the `noqa` comment begins with an octothorpe followed by a space. (`# `) With anyone's random code, this of course is not always true. When there's a multi-byte character after the leading octothorpe, such as [`\u0085`](https://www.fileformat.info/info/unicode/char/85/index.htm), we try slicing from within the character, causing a panic. To fix this, the logic has been changed to remove unused `noqa` directives and keep any trailing comments, or removing the whole comment if the comment is just the unused `noqa` Fixes #10097. ## Test Plan `cargo test`
- Loading branch information
1 parent
9f2127b
commit f6b6f0d
Showing
4 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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 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