Skip to content

Commit

Permalink
Skip if f-string isn't multi-line
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Sep 20, 2023
1 parent 25b81ea commit e01be7c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/ruff/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ fn extract_noqa_line_for(lxr: &[LexResult], locator: &Locator, indexer: &Indexer
// the inner f-strings.
let mut last_fstring_range: TextRange = TextRange::default();
for fstring_range in indexer.fstring_ranges().values() {
if !locator.contains_line_break(*fstring_range) {
continue;
}
if last_fstring_range.contains_range(*fstring_range) {
continue;
}
Expand Down Expand Up @@ -514,6 +517,12 @@ end'''
NoqaMapping::from_iter([TextRange::new(TextSize::from(6), TextSize::from(70))])
);

let contents = "x = 1
y = f'normal'
z = f'another but {f'nested but {f'still single line'} nested'}'
";
assert_eq!(noqa_mappings(contents), NoqaMapping::default());

let contents = r"x = \
1";
assert_eq!(
Expand Down

0 comments on commit e01be7c

Please sign in to comment.