From ce7df06978bbb363c0bead231e306b488ab543ae Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 18 Aug 2024 18:55:00 -0400 Subject: [PATCH] Ignore unused arguments on stub functions --- crates/ruff/tests/lint.rs | 2 +- .../rules/unused_arguments.rs | 1 + ...nused_arguments__tests__ARG001_ARG.py.snap | 30 ------------------- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/crates/ruff/tests/lint.rs b/crates/ruff/tests/lint.rs index 8541a2492ba77..7209f33e5b46a 100644 --- a/crates/ruff/tests/lint.rs +++ b/crates/ruff/tests/lint.rs @@ -1434,7 +1434,7 @@ def unused(x): insta::assert_snapshot!(test_code, @r###" - def unused(x): # noqa: ANN001, ANN201, ARG001, D103 + def unused(x): # noqa: ANN001, ANN201, D103 pass "###); diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs b/crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs index 558b408831302..beabe2e33917f 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/rules/unused_arguments.rs @@ -344,6 +344,7 @@ pub(crate) fn unused_arguments( ) { function_type::FunctionType::Function => { if checker.enabled(Argumentable::Function.rule_code()) + && !function_type::is_stub(function_def, checker.semantic()) && !visibility::is_overload(decorator_list, checker.semantic()) { function( diff --git a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap index c5b77b6f82c41..0b65aed7a13d0 100644 --- a/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap +++ b/crates/ruff_linter/src/rules/flake8_unused_arguments/snapshots/ruff_linter__rules__flake8_unused_arguments__tests__ARG001_ARG.py.snap @@ -32,33 +32,3 @@ ARG.py:13:12: ARG001 Unused function argument: `x` | ^ ARG001 14 | print("Hello, world!") | - -ARG.py:17:7: ARG001 Unused function argument: `self` - | -17 | def f(self, x): - | ^^^^ ARG001 -18 | ... - | - -ARG.py:17:13: ARG001 Unused function argument: `x` - | -17 | def f(self, x): - | ^ ARG001 -18 | ... - | - -ARG.py:21:7: ARG001 Unused function argument: `cls` - | -21 | def f(cls, x): - | ^^^ ARG001 -22 | ... - | - -ARG.py:21:12: ARG001 Unused function argument: `x` - | -21 | def f(cls, x): - | ^ ARG001 -22 | ... - | - -