Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
da0d858
tests and snapshots to capture current behavior
dylwil3 Mar 3, 2025
386017e
match function signatures for directive and file exemption
dylwil3 Mar 3, 2025
3c8e023
test that code text matches slice at range
dylwil3 Mar 3, 2025
8e06ad5
core parsing reimplementation
dylwil3 Mar 3, 2025
a7ec02c
update snapshots for parsing behavior
dylwil3 Mar 3, 2025
fa96a03
update noqa.py fixture and snapshot for new behavior
dylwil3 Mar 3, 2025
b5949d5
emit warnings for inline and file-level exemptions
dylwil3 Mar 3, 2025
418d2a7
include warnings in snapshot tests
dylwil3 Mar 3, 2025
83d4c46
remove ParsedFileExemption
dylwil3 Mar 3, 2025
2ea73c0
remove Directive::lex_code
dylwil3 Mar 3, 2025
d8b9052
replace ParsedNoqaDirective with Directive everywhere
dylwil3 Mar 3, 2025
b6f66ce
clippy
dylwil3 Mar 3, 2025
2ac597b
ascii whitespace only in regex
dylwil3 Mar 3, 2025
0c45ccf
revert "ascii whitespace only in regex" and try again
dylwil3 Mar 3, 2025
f88cc8d
try explicit case-insensitive
dylwil3 Mar 3, 2025
6be00e0
hand roll noqa prefix regex
dylwil3 Mar 4, 2025
018fa03
hand roll file exemption prefix regex
dylwil3 Mar 4, 2025
de4e5eb
rewrite noqa parser with Cursor
dylwil3 Mar 6, 2025
6dd06d3
update snapshots
dylwil3 Mar 7, 2025
81714fb
use public lex_codes for blanket noqa rule
dylwil3 Mar 7, 2025
de9284c
truncate source range end to comment range before lexing
dylwil3 Mar 7, 2025
5f85a75
use text_len
dylwil3 Mar 7, 2025
90f3be3
typo lexess->lexes
dylwil3 Mar 7, 2025
a3eb354
allow non ascii whitespace in comment after All noqa
dylwil3 Mar 7, 2025
0bedda2
fold prefix stripping into lexer
dylwil3 Mar 7, 2025
3de925d
smaller diff for tests
dylwil3 Mar 10, 2025
729a092
in_range instead of starts_at
dylwil3 Mar 10, 2025
03cca16
eat_whitespace method
dylwil3 Mar 10, 2025
b580b93
test case with leading hashes and spaces
dylwil3 Mar 10, 2025
f190d53
nit: simplify skip of tool prefix
dylwil3 Mar 10, 2025
8069e66
allow spaces after noqa and before colon
dylwil3 Mar 10, 2025
81709fc
nit: rename current to position
dylwil3 Mar 10, 2025
1b108b3
remove need to store line in lexer
dylwil3 Mar 10, 2025
70c22f6
example comment for whitespace delimiters
dylwil3 Mar 10, 2025
bde12ae
space before colon no longer possible in blanket noqa PGH004
dylwil3 Mar 10, 2025
6b5d25b
clippy
dylwil3 Mar 10, 2025
d48bb11
just allow arbitrary whitespace it's not a big deal
dylwil3 Mar 10, 2025
ae39f61
remove unreachable branch in PGH004 implementation
dylwil3 Mar 10, 2025
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
3 changes: 2 additions & 1 deletion crates/ruff_linter/resources/test/fixtures/ruff/noqa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 8 additions & 1 deletion crates/ruff_linter/src/checkers/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion crates/ruff_linter/src/checkers/noqa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![];
Expand Down
Loading
Loading