Skip to content

Commit

Permalink
Remove redundant arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Aug 13, 2024
1 parent dda1efa commit 452fbd9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
8 changes: 1 addition & 7 deletions crates/ruff_linter/src/checkers/ast/analyze/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,7 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
Rule::SuperfluousElseContinue,
Rule::SuperfluousElseBreak,
]) {
flake8_return::rules::function(
checker,
function_def,
body,
decorator_list,
returns.as_ref().map(AsRef::as_ref),
);
flake8_return::rules::function(checker, function_def);
}
if checker.enabled(Rule::UselessReturn) {
pylint::rules::useless_return(
Expand Down
17 changes: 9 additions & 8 deletions crates/ruff_linter/src/rules/flake8_return/rules/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,13 +764,14 @@ fn superfluous_elif_else(checker: &mut Checker, stack: &Stack) {
}

/// Run all checks from the `flake8-return` plugin.
pub(crate) fn function(
checker: &mut Checker,
function_def: &ast::StmtFunctionDef,
body: &[Stmt],
decorator_list: &[Decorator],
returns: Option<&Expr>,
) {
pub(crate) fn function(checker: &mut Checker, function_def: &ast::StmtFunctionDef) {
let ast::StmtFunctionDef {
decorator_list,
returns,
body,
..
} = function_def;

// Find the last statement in the function.
let Some(last_stmt) = body.last() else {
// Skip empty functions.
Expand Down Expand Up @@ -825,7 +826,7 @@ pub(crate) fn function(
} else {
if checker.enabled(Rule::UnnecessaryReturnNone) {
// Skip functions that have a return annotation that is not `None`.
if returns.map_or(true, Expr::is_none_literal_expr) {
if returns.as_deref().map_or(true, Expr::is_none_literal_expr) {
unnecessary_return_none(checker, decorator_list, &stack);
}
}
Expand Down

0 comments on commit 452fbd9

Please sign in to comment.