mirror of https://github.com/astral-sh/ruff
Remove unnecessary mutable variable `has_parameters` (#8124)
This commit is contained in:
parent
2c2ebf952a
commit
c0710a1dd4
|
|
@ -167,23 +167,24 @@ fn check_useless_usefixtures(checker: &mut Checker, decorator: &Decorator, marke
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut has_parameters = false;
|
match &decorator.expression {
|
||||||
|
// @pytest.mark.usefixtures
|
||||||
if let Expr::Call(ast::ExprCall {
|
Expr::Attribute(..) => {}
|
||||||
arguments: Arguments { args, keywords, .. },
|
// @pytest.mark.usefixtures(...)
|
||||||
..
|
Expr::Call(ast::ExprCall {
|
||||||
}) = &decorator.expression
|
arguments: Arguments { args, keywords, .. },
|
||||||
{
|
..
|
||||||
if !args.is_empty() || !keywords.is_empty() {
|
}) => {
|
||||||
has_parameters = true;
|
if !args.is_empty() || !keywords.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
_ => return,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !has_parameters {
|
let mut diagnostic = Diagnostic::new(PytestUseFixturesWithoutParameters, decorator.range());
|
||||||
let mut diagnostic = Diagnostic::new(PytestUseFixturesWithoutParameters, decorator.range());
|
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_deletion(decorator.range())));
|
||||||
diagnostic.set_fix(Fix::unsafe_edit(Edit::range_deletion(decorator.range())));
|
checker.diagnostics.push(diagnostic);
|
||||||
checker.diagnostics.push(diagnostic);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn marks(checker: &mut Checker, decorators: &[Decorator]) {
|
pub(crate) fn marks(checker: &mut Checker, decorators: &[Decorator]) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue