Skip to content

Commit 4c4d43d

Browse files
authored
[pep8-naming]: Ignore methods decorated with @typing.override (invalid-argument-name) (#16667)
## Summary This PR stabilizes the preview behavior for `invalid-argument-name` (`N803`) to ignore argument names of functions decorated with `typing.override` because these methods are *out of the authors* control. This behavior was introduced in #15954 and released as part of Ruff 0.9.5 (6th of February). There have been no new issues or PRs since this behavior change (preview) was introduced.
1 parent 7672dd0 commit 4c4d43d

File tree

4 files changed

+2
-49
lines changed

4 files changed

+2
-49
lines changed

crates/ruff_linter/src/rules/pep8_naming/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ mod tests {
8989
Ok(())
9090
}
9191

92-
#[test_case(Rule::InvalidArgumentName, Path::new("N803.py"))]
9392
#[test_case(Rule::InvalidArgumentName, Path::new("N804.py"))]
9493
fn preview_rules(rule_code: Rule, path: &Path) -> Result<()> {
9594
let snapshot = format!(

crates/ruff_linter/src/rules/pep8_naming/rules/invalid_argument_name.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use crate::checkers::ast::Checker;
2323
/// > mixedCase is allowed only in contexts where that’s already the
2424
/// > prevailing style (e.g. threading.py), to retain backwards compatibility.
2525
///
26-
/// In [preview], overridden methods are ignored.
26+
/// Methods decorated with `@typing.override` are ignored.
2727
///
2828
/// ## Example
2929
/// ```python
@@ -61,8 +61,7 @@ pub(crate) fn invalid_argument_name_function(checker: &Checker, function_def: &S
6161
let semantic = checker.semantic();
6262
let scope = semantic.current_scope();
6363

64-
if checker.settings.preview.is_enabled()
65-
&& matches!(scope.kind, ScopeKind::Class(_))
64+
if matches!(scope.kind, ScopeKind::Class(_))
6665
&& is_override(&function_def.decorator_list, semantic)
6766
{
6867
return;

crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__N803_N803.py.snap

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ N803.py:6:28: N803 Argument name `A` should be lowercase
1616
7 | return _, a, A
1717
|
1818

19-
N803.py:18:28: N803 Argument name `A` should be lowercase
20-
|
21-
16 | class Extended(Class):
22-
17 | @override
23-
18 | def method(self, _, a, A): ...
24-
| ^ N803
25-
|
26-
2719
N803.py:22:16: N803 Argument name `A` should be lowercase
2820
|
2921
21 | @override # Incorrect usage

crates/ruff_linter/src/rules/pep8_naming/snapshots/ruff_linter__rules__pep8_naming__tests__preview__N803_N803.py.snap

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)