Skip to content

Commit

Permalink
Remove unnecessary mutable variable has_parameters (#8124)
Browse files Browse the repository at this point in the history
  • Loading branch information
harupy authored Oct 23, 2023
1 parent 2c2ebf9 commit c0710a1
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions crates/ruff_linter/src/rules/flake8_pytest_style/rules/marks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,24 @@ fn check_useless_usefixtures(checker: &mut Checker, decorator: &Decorator, marke
return;
}

let mut has_parameters = false;

if let Expr::Call(ast::ExprCall {
arguments: Arguments { args, keywords, .. },
..
}) = &decorator.expression
{
if !args.is_empty() || !keywords.is_empty() {
has_parameters = true;
match &decorator.expression {
// @pytest.mark.usefixtures
Expr::Attribute(..) => {}
// @pytest.mark.usefixtures(...)
Expr::Call(ast::ExprCall {
arguments: Arguments { args, keywords, .. },
..
}) => {
if !args.is_empty() || !keywords.is_empty() {
return;
}
}
_ => return,
}

if !has_parameters {
let mut diagnostic = Diagnostic::new(PytestUseFixturesWithoutParameters, decorator.range());
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_deletion(decorator.range())));
checker.diagnostics.push(diagnostic);
}
let mut diagnostic = Diagnostic::new(PytestUseFixturesWithoutParameters, decorator.range());
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_deletion(decorator.range())));
checker.diagnostics.push(diagnostic);
}

pub(crate) fn marks(checker: &mut Checker, decorators: &[Decorator]) {
Expand Down

0 comments on commit c0710a1

Please sign in to comment.