diff --git a/crates/ruff_linter/resources/test/fixtures/ruff/noqa.py b/crates/ruff_linter/resources/test/fixtures/ruff/noqa.py
index 30e59400c6..f91ab752ac 100644
--- a/crates/ruff_linter/resources/test/fixtures/ruff/noqa.py
+++ b/crates/ruff_linter/resources/test/fixtures/ruff/noqa.py
@@ -19,5 +19,6 @@ def f():
def f():
- # Only `E741` should be ignored by the `noqa`.
+ # Neither of these are ignored and warning is
+ # logged to user
I = 1 # noqa: E741.F841
diff --git a/crates/ruff_linter/src/checkers/ast/mod.rs b/crates/ruff_linter/src/checkers/ast/mod.rs
index c4f98433bd..6d195e41bf 100644
--- a/crates/ruff_linter/src/checkers/ast/mod.rs
+++ b/crates/ruff_linter/src/checkers/ast/mod.rs
@@ -293,7 +293,14 @@ impl<'a> Checker<'a> {
if !self.noqa.is_enabled() {
return false;
}
- noqa::rule_is_ignored(code, offset, self.noqa_line_for, self.locator)
+
+ noqa::rule_is_ignored(
+ code,
+ offset,
+ self.noqa_line_for,
+ self.comment_ranges(),
+ self.locator,
+ )
}
/// Create a [`Generator`] to generate source code based on the current AST state.
diff --git a/crates/ruff_linter/src/checkers/noqa.rs b/crates/ruff_linter/src/checkers/noqa.rs
index c48ab99ad5..4d3015eadd 100644
--- a/crates/ruff_linter/src/checkers/noqa.rs
+++ b/crates/ruff_linter/src/checkers/noqa.rs
@@ -38,7 +38,8 @@ pub(crate) fn check_noqa(
let exemption = FileExemption::from(&file_noqa_directives);
// Extract all `noqa` directives.
- let mut noqa_directives = NoqaDirectives::from_commented_ranges(comment_ranges, path, locator);
+ let mut noqa_directives =
+ NoqaDirectives::from_commented_ranges(comment_ranges, &settings.external, path, locator);
// Indices of diagnostics that were ignored by a `noqa` directive.
let mut ignored_diagnostics = vec![];
diff --git a/crates/ruff_linter/src/noqa.rs b/crates/ruff_linter/src/noqa.rs
index ac8d2cf552..ef0ae63f8b 100644
--- a/crates/ruff_linter/src/noqa.rs
+++ b/crates/ruff_linter/src/noqa.rs
@@ -10,7 +10,7 @@ use itertools::Itertools;
use log::warn;
use ruff_diagnostics::{Diagnostic, Edit};
-use ruff_python_trivia::{indentation_at_offset, CommentRanges};
+use ruff_python_trivia::{indentation_at_offset, CommentRanges, Cursor};
use ruff_source_file::{LineEnding, LineRanges};
use ruff_text_size::{Ranged, TextLen, TextRange, TextSize};
@@ -36,13 +36,13 @@ pub fn generate_noqa_edits(
) -> Vec