Skip to content
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

W191 isn't triggered inside multi-line f-string expression #7379

Closed
dhruvmanila opened this issue Sep 14, 2023 · 1 comment · Fixed by #7435
Closed

W191 isn't triggered inside multi-line f-string expression #7379

dhruvmanila opened this issue Sep 14, 2023 · 1 comment · Fixed by #7435
Labels
bug Something isn't working

Comments

@dhruvmanila
Copy link
Member

Code snippet:

f"""test{
	tab_indented_should_be_flagged
}	<- this tab is fine"""

Command:

ruff check --no-cache --select=W191 --isolated test.py

Rule reference: https://beta.ruff.rs/docs/rules/tab-indentation/

@dhruvmanila dhruvmanila added the bug Something isn't working label Sep 14, 2023
@dhruvmanila
Copy link
Member Author

(I would wait until PEP 701 support is merged as the implementation might change)

dhruvmanila added a commit that referenced this issue Sep 16, 2023
## Summary

This PR updates the `W191` (`tab-indentation`) rule from a line-based to
a token-based rule.

Earlier, the rule used the `triple_quoted_string_ranges` from the
indexer to skip 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_ranges` from
the 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`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant