-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect
noqa
directives for multi-line f-strings (#7326)
## Summary This PR updates the NoQA directive detection to consider the new f-string tokens. The reason being that now there can be multi-line f-strings without triple-quotes: ```python f"{ x * y }" ``` Here, the `noqa` directive should go at the end of the last line. ## Test Plan * Add new test cases for f-strings * Tested with `--add-noqa` using the following command with the above code snippet: ```console $ cargo run --bin ruff -- check --select=F821 --no-cache --isolated ~/playground/ruff/fstring.py --add-noqa Added 1 noqa directive. ``` Output: ```python f"{ x * y }" # noqa: F821 ``` Running the same command again doesn't add `noqa` directive and without the `--add-noqa` flag, the violation isn't reported. fixes: #7291
- Loading branch information
1 parent
14a723d
commit dd95717
Showing
3 changed files
with
154 additions
and
24 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