Skip to content

Commit ac94d4a

Browse files
committed
Implement rule
1 parent 2f30854 commit ac94d4a

File tree

1 file changed

+9
-3
lines changed
  • crates/ruff_linter/src/rules/flake8_return/rules

1 file changed

+9
-3
lines changed

crates/ruff_linter/src/rules/flake8_return/rules/function.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use anyhow::Result;
55
use ruff_diagnostics::{AlwaysFixableViolation, FixAvailability, Violation};
66
use ruff_diagnostics::{Diagnostic, Edit, Fix};
77
use ruff_macros::{derive_message_formats, violation};
8-
use ruff_python_ast::helpers::{is_const_false, is_const_true};
8+
use ruff_python_ast::helpers::{is_const_false, is_const_true, map_callable};
99
use ruff_python_ast::stmt_if::elif_else_range;
1010
use ruff_python_ast::visitor::Visitor;
1111
use ruff_python_ast::whitespace::indentation;
@@ -373,11 +373,17 @@ fn unnecessary_return_none(checker: &mut Checker, decorator_list: &[Decorator],
373373
continue;
374374
}
375375

376-
// Skip properties.
376+
// Skip properties and cached properties.
377377
if decorator_list.iter().any(|decorator| {
378378
checker
379379
.semantic()
380-
.match_builtin_expr(&decorator.expression, "property")
380+
.resolve_qualified_name(map_callable(&decorator.expression))
381+
.is_some_and(|qualified_name| {
382+
matches!(
383+
qualified_name.segments(),
384+
["" | "builtins", "property"] | ["functools", "cached_property"]
385+
)
386+
})
381387
}) {
382388
return;
383389
}

0 commit comments

Comments
 (0)