Skip to content

Commit

Permalink
Remove mut
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jan 18, 2024
1 parent a8e2f5c commit 53ee98a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions crates/ruff_linter/src/rules/pylint/rules/too_many_positional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ impl Violation for TooManyPositional {

/// PLR0917
pub(crate) fn too_many_positional(checker: &mut Checker, function_def: &ast::StmtFunctionDef) {
let mut num_positional_args = function_def
let semantic = checker.semantic();

// Count the number of positional arguments.
let num_positional_args = function_def
.parameters
.args
.iter()
Expand All @@ -70,10 +73,8 @@ pub(crate) fn too_many_positional(checker: &mut Checker, function_def: &ast::Stm
})
.count();

let semantic = checker.semantic();

// Check if the function is a method or class method.
if matches!(
let num_positional_args = if matches!(
function_type::classify(
&function_def.name,
&function_def.decorator_list,
Expand All @@ -86,8 +87,10 @@ pub(crate) fn too_many_positional(checker: &mut Checker, function_def: &ast::Stm
) {
// If so, we need to subtract one from the number of positional arguments, since the first
// argument is always `self` or `cls`.
num_positional_args = num_positional_args.saturating_sub(1);
}
num_positional_args.saturating_sub(1)
} else {
num_positional_args
};

if num_positional_args > checker.settings.pylint.max_positional_args {
// Allow excessive arguments in `@override` or `@overload` methods, since they're required
Expand Down

0 comments on commit 53ee98a

Please sign in to comment.