mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 14:21:24 +00:00
Avoid respecting noqa directives when RUF100 is enabled (#3469)
This commit is contained in:
parent
6c576872d4
commit
a65c6806a6
2 changed files with 8 additions and 5 deletions
|
@ -22,7 +22,7 @@ pub fn check_noqa(
|
|||
noqa_line_for: &IntMap<usize, usize>,
|
||||
settings: &Settings,
|
||||
autofix: flags::Autofix,
|
||||
) {
|
||||
) -> Vec<usize> {
|
||||
let enforce_noqa = settings.rules.enabled(&Rule::UnusedNOQA);
|
||||
|
||||
// Whether the file is exempted from all checks.
|
||||
|
@ -264,7 +264,5 @@ pub fn check_noqa(
|
|||
}
|
||||
|
||||
ignored_diagnostics.sort_unstable();
|
||||
for index in ignored_diagnostics.iter().rev() {
|
||||
diagnostics.swap_remove(*index);
|
||||
}
|
||||
ignored_diagnostics
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ pub fn check_path(
|
|||
.iter_enabled()
|
||||
.any(|rule_code| rule_code.lint_source().is_noqa())
|
||||
{
|
||||
check_noqa(
|
||||
let ignored = check_noqa(
|
||||
&mut diagnostics,
|
||||
contents,
|
||||
indexer.commented_lines(),
|
||||
|
@ -223,6 +223,11 @@ pub fn check_path(
|
|||
settings,
|
||||
error.as_ref().map_or(autofix, |_| flags::Autofix::Disabled),
|
||||
);
|
||||
if noqa.into() {
|
||||
for index in ignored.iter().rev() {
|
||||
diagnostics.swap_remove(*index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LinterResult::new(diagnostics, error)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue