Skip to content

Commit 3e366fd

Browse files
authored
[refurb] Ignore decorated functions for FURB118 (#19339)
## Summary Fixes #19305
1 parent 53e9e44 commit 3e366fd

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

crates/ruff_linter/resources/test/fixtures/refurb/FURB118.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,23 @@ class NotAMethodButHardToDetect:
143143
# without risking false positives elsewhere or introducing complex heuristics
144144
# that users would find surprising and confusing
145145
FOO = sorted([x for x in BAR], key=lambda x: x.baz)
146+
147+
# https://github.com/astral-sh/ruff/issues/19305
148+
import pytest
149+
150+
@pytest.fixture
151+
def my_fixture_with_param(request):
152+
return request.param
153+
154+
@pytest.fixture()
155+
def my_fixture_with_param2(request):
156+
return request.param
157+
158+
159+
# Decorated function (should be ignored)
160+
def custom_decorator(func):
161+
return func
162+
163+
@custom_decorator
164+
def add(x, y):
165+
return x + y

crates/ruff_linter/src/rules/refurb/rules/reimplemented_operator.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ pub(crate) fn reimplemented_operator(checker: &Checker, target: &FunctionLike) {
104104
return;
105105
}
106106

107+
// Skip decorated functions
108+
if let FunctionLike::Function(func) = target {
109+
if !func.decorator_list.is_empty() {
110+
return;
111+
}
112+
}
113+
107114
let Some(params) = target.parameters() else {
108115
return;
109116
};

0 commit comments

Comments
 (0)