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>,
|
noqa_line_for: &IntMap<usize, usize>,
|
||||||
settings: &Settings,
|
settings: &Settings,
|
||||||
autofix: flags::Autofix,
|
autofix: flags::Autofix,
|
||||||
) {
|
) -> Vec<usize> {
|
||||||
let enforce_noqa = settings.rules.enabled(&Rule::UnusedNOQA);
|
let enforce_noqa = settings.rules.enabled(&Rule::UnusedNOQA);
|
||||||
|
|
||||||
// Whether the file is exempted from all checks.
|
// Whether the file is exempted from all checks.
|
||||||
|
@ -264,7 +264,5 @@ pub fn check_noqa(
|
||||||
}
|
}
|
||||||
|
|
||||||
ignored_diagnostics.sort_unstable();
|
ignored_diagnostics.sort_unstable();
|
||||||
for index in ignored_diagnostics.iter().rev() {
|
ignored_diagnostics
|
||||||
diagnostics.swap_remove(*index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ pub fn check_path(
|
||||||
.iter_enabled()
|
.iter_enabled()
|
||||||
.any(|rule_code| rule_code.lint_source().is_noqa())
|
.any(|rule_code| rule_code.lint_source().is_noqa())
|
||||||
{
|
{
|
||||||
check_noqa(
|
let ignored = check_noqa(
|
||||||
&mut diagnostics,
|
&mut diagnostics,
|
||||||
contents,
|
contents,
|
||||||
indexer.commented_lines(),
|
indexer.commented_lines(),
|
||||||
|
@ -223,6 +223,11 @@ pub fn check_path(
|
||||||
settings,
|
settings,
|
||||||
error.as_ref().map_or(autofix, |_| flags::Autofix::Disabled),
|
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)
|
LinterResult::new(diagnostics, error)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue