Skip to content

Commit 80ade59

Browse files
Ignore unused arguments on stub functions (#12966)
## Summary We already enforce this logic for the other `ARG` rules. I'm guessing this was an oversight. Closes #12963.
1 parent 4881d32 commit 80ade59

File tree

3 files changed

+2
-31
lines changed

3 files changed

+2
-31
lines changed

crates/ruff/tests/lint.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ def unused(x):
14341434

14351435
insta::assert_snapshot!(test_code, @r###"
14361436
1437-
def unused(x): # noqa: ANN001, ANN201, ARG001, D103
1437+
def unused(x): # noqa: ANN001, ANN201, D103
14381438
pass
14391439
"###);
14401440

crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs

+1
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ pub(crate) fn unused_arguments(
344344
) {
345345
function_type::FunctionType::Function => {
346346
if checker.enabled(Argumentable::Function.rule_code())
347+
&& !function_type::is_stub(function_def, checker.semantic())
347348
&& !visibility::is_overload(decorator_list, checker.semantic())
348349
{
349350
function(

crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap

-30
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,3 @@ ARG.py:13:12: ARG001 Unused function argument: `x`
3232
| ^ ARG001
3333
14 | print("Hello, world!")
3434
|
35-
36-
ARG.py:17:7: ARG001 Unused function argument: `self`
37-
|
38-
17 | def f(self, x):
39-
| ^^^^ ARG001
40-
18 | ...
41-
|
42-
43-
ARG.py:17:13: ARG001 Unused function argument: `x`
44-
|
45-
17 | def f(self, x):
46-
| ^ ARG001
47-
18 | ...
48-
|
49-
50-
ARG.py:21:7: ARG001 Unused function argument: `cls`
51-
|
52-
21 | def f(cls, x):
53-
| ^^^ ARG001
54-
22 | ...
55-
|
56-
57-
ARG.py:21:12: ARG001 Unused function argument: `x`
58-
|
59-
21 | def f(cls, x):
60-
| ^ ARG001
61-
22 | ...
62-
|
63-
64-

0 commit comments

Comments
 (0)