Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/ruff_linter/src/checkers/noqa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ pub(crate) fn check_noqa(
&noqa_directives,
locator,
&file_noqa_directives,
settings.preview,
);
}

Expand Down
19 changes: 0 additions & 19 deletions crates/ruff_linter/src/rules/pygrep_hooks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ mod tests {

use crate::registry::Rule;

use crate::settings::types::PreviewMode;
use crate::test::test_path;
use crate::{assert_messages, settings};

Expand All @@ -30,22 +29,4 @@ mod tests {
assert_messages!(snapshot, diagnostics);
Ok(())
}

#[test_case(Rule::BlanketNOQA, Path::new("PGH004_2.py"))]
fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> {
let snapshot = format!(
"preview__{}_{}",
rule_code.noqa_code(),
path.to_string_lossy()
);
let diagnostics = test_path(
Path::new("pygrep_hooks").join(path).as_path(),
&settings::LinterSettings {
preview: PreviewMode::Enabled,
..settings::LinterSettings::for_rule(rule_code)
},
)?;
assert_messages!(snapshot, diagnostics);
Ok(())
}
}
27 changes: 9 additions & 18 deletions crates/ruff_linter/src/rules/pygrep_hooks/rules/blanket_noqa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use ruff_python_trivia::Cursor;
use ruff_text_size::{Ranged, TextRange};

use crate::noqa::{self, Directive, FileNoqaDirectives, NoqaDirectives};
use crate::settings::types::PreviewMode;
use crate::Locator;

/// ## What it does
Expand All @@ -18,9 +17,6 @@ use crate::Locator;
/// maintain, as the annotation does not clarify which diagnostics are intended
/// to be suppressed.
///
/// In [preview], this rule also checks for blanket file-level annotations (e.g.,
/// `# ruff: noqa`, as opposed to `# ruff: noqa: F401`).
///
/// ## Example
/// ```python
/// from .base import * # noqa
Expand All @@ -41,8 +37,6 @@ use crate::Locator;
///
/// ## References
/// - [Ruff documentation](https://docs.astral.sh/ruff/configuration/#error-suppression)
///
/// [preview]: https://docs.astral.sh/ruff/preview/
#[derive(ViolationMetadata)]
pub(crate) struct BlanketNOQA {
missing_colon: bool,
Expand Down Expand Up @@ -84,19 +78,16 @@ pub(crate) fn blanket_noqa(
noqa_directives: &NoqaDirectives,
locator: &Locator,
file_noqa_directives: &FileNoqaDirectives,
preview: PreviewMode,
) {
if preview.is_enabled() {
for line in file_noqa_directives.lines() {
if let Directive::All(_) = line.parsed_file_exemption {
diagnostics.push(Diagnostic::new(
BlanketNOQA {
missing_colon: false,
file_exemption: true,
},
line.range(),
));
}
for line in file_noqa_directives.lines() {
if let Directive::All(_) = line.parsed_file_exemption {
diagnostics.push(Diagnostic::new(
BlanketNOQA {
missing_colon: false,
file_exemption: true,
},
line.range(),
));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
source: crates/ruff_linter/src/rules/pygrep_hooks/mod.rs
snapshot_kind: text
---
PGH004_2.py:1:1: PGH004 Use specific rule codes when using `noqa`
|
Expand All @@ -9,3 +8,18 @@ PGH004_2.py:1:1: PGH004 Use specific rule codes when using `noqa`
2 | # ruff : noqa
3 | # ruff: noqa: F401
|

PGH004_2.py:2:1: PGH004 Use specific rule codes when using `ruff: noqa`
|
1 | # noqa
2 | # ruff : noqa
| ^^^^^^^^^^^^^ PGH004
3 | # ruff: noqa: F401
|

PGH004_2.py:6:1: PGH004 Use specific rule codes when using `ruff: noqa`
|
6 | # flake8: noqa
| ^^^^^^^^^^^^^^ PGH004
7 | import math as m
|

This file was deleted.

Loading