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
18 changes: 18 additions & 0 deletions resources/test/fixtures/flake8_unused_arguments/ARG.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from abc import abstractmethod
from typing import overload
from typing_extensions import override


Expand Down Expand Up @@ -135,3 +136,20 @@ def f(cls, x):
@override
def f(x):
print("Hello, world!")


###
# Unused arguments attached to overloads (OK).
###
@overload
def f(a: str, b: str) -> str:
...


@overload
def f(a: int, b: int) -> str:
...


def f(a, b):
return f"{a}{b}"
4 changes: 4 additions & 0 deletions src/flake8_unused_arguments/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pub fn unused_arguments(
.settings
.enabled
.contains(Argumentable::Function.check_code())
&& !visibility::is_overload(checker, decorator_list)
{
function(
&Argumentable::Function,
Expand All @@ -154,6 +155,7 @@ pub fn unused_arguments(
&& !helpers::is_empty(body)
&& !visibility::is_abstract(checker, decorator_list)
&& !visibility::is_override(checker, decorator_list)
&& !visibility::is_overload(checker, decorator_list)
{
method(
&Argumentable::Method,
Expand All @@ -178,6 +180,7 @@ pub fn unused_arguments(
&& !helpers::is_empty(body)
&& !visibility::is_abstract(checker, decorator_list)
&& !visibility::is_override(checker, decorator_list)
&& !visibility::is_overload(checker, decorator_list)
{
method(
&Argumentable::ClassMethod,
Expand All @@ -202,6 +205,7 @@ pub fn unused_arguments(
&& !helpers::is_empty(body)
&& !visibility::is_abstract(checker, decorator_list)
&& !visibility::is_override(checker, decorator_list)
&& !visibility::is_overload(checker, decorator_list)
{
function(
&Argumentable::StaticMethod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,73 +5,73 @@ expression: checks
- kind:
UnusedFunctionArgument: self
location:
row: 8
row: 9
column: 6
end_location:
row: 8
row: 9
column: 10
fix: ~
- kind:
UnusedFunctionArgument: x
location:
row: 8
row: 9
column: 12
end_location:
row: 8
row: 9
column: 13
fix: ~
- kind:
UnusedFunctionArgument: cls
location:
row: 12
row: 13
column: 6
end_location:
row: 12
row: 13
column: 9
fix: ~
- kind:
UnusedFunctionArgument: x
location:
row: 12
row: 13
column: 11
end_location:
row: 12
row: 13
column: 12
fix: ~
- kind:
UnusedFunctionArgument: self
location:
row: 16
row: 17
column: 6
end_location:
row: 16
row: 17
column: 10
fix: ~
- kind:
UnusedFunctionArgument: x
location:
row: 16
row: 17
column: 12
end_location:
row: 16
row: 17
column: 13
fix: ~
- kind:
UnusedFunctionArgument: cls
location:
row: 20
row: 21
column: 6
end_location:
row: 20
row: 21
column: 9
fix: ~
- kind:
UnusedFunctionArgument: x
location:
row: 20
row: 21
column: 11
end_location:
row: 20
row: 21
column: 12
fix: ~

Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ expression: checks
- kind:
UnusedMethodArgument: x
location:
row: 34
row: 35
column: 16
end_location:
row: 34
row: 35
column: 17
fix: ~
- kind:
UnusedMethodArgument: x
location:
row: 37
row: 38
column: 19
end_location:
row: 37
row: 38
column: 20
fix: ~
- kind:
UnusedMethodArgument: x
location:
row: 40
row: 41
column: 15
end_location:
row: 40
row: 41
column: 16
fix: ~

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ expression: checks
- kind:
UnusedClassMethodArgument: x
location:
row: 44
row: 45
column: 15
end_location:
row: 44
row: 45
column: 16
fix: ~

Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@ expression: checks
- kind:
UnusedStaticMethodArgument: cls
location:
row: 48
row: 49
column: 10
end_location:
row: 48
row: 49
column: 13
fix: ~
- kind:
UnusedStaticMethodArgument: x
location:
row: 48
row: 49
column: 15
end_location:
row: 48
row: 49
column: 16
fix: ~
- kind:
UnusedStaticMethodArgument: x
location:
row: 52
row: 53
column: 10
end_location:
row: 52
row: 53
column: 11
fix: ~

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ expression: checks
- kind:
UnusedLambdaArgument: x
location:
row: 27
row: 28
column: 7
end_location:
row: 27
row: 28
column: 8
fix: ~