Skip to content

Commit

Permalink
Ignore string if it is inside a f-string
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Mar 10, 2024
1 parent 1e24c01 commit d30dc29
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,16 @@ fn strings(checker: &mut Checker, sequence: &[TextRange]) {

/// Generate `flake8-quote` diagnostics from a token stream.
pub(crate) fn check_string_quotes(checker: &mut Checker, string_like: StringLike) {
// If the string is part of a f-string, ignore it.
if checker
.indexer()
.fstring_ranges()
.outermost(string_like.start())
.is_some_and(|outer_range| outer_range != string_like.range())
{
return;
}

let ranges: Vec<TextRange> = match string_like {
StringLike::String(node) => node.value.iter().map(Ranged::range).collect(),
StringLike::Bytes(node) => node.value.iter().map(Ranged::range).collect(),
Expand Down

0 comments on commit d30dc29

Please sign in to comment.