diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fail.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fail.rs index 1d98abb3f1..b00ea5b0db 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fail.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/fail.rs @@ -59,18 +59,12 @@ pub(crate) fn fail_call(checker: &mut Checker, call: &ast::ExprCall) { if is_pytest_fail(&call.func, checker.semantic()) { // Allow either `pytest.fail(reason="...")` (introduced in pytest 7.0) or // `pytest.fail(msg="...")` (deprecated in pytest 7.0) - let msg = call + if call .arguments .find_argument("reason", 0) - .or_else(|| call.arguments.find_argument("msg", 0)); - - if let Some(msg) = msg { - if is_empty_or_null_string(msg) { - checker - .diagnostics - .push(Diagnostic::new(PytestFailWithoutMessage, call.func.range())); - } - } else { + .or_else(|| call.arguments.find_argument("msg", 0)) + .map_or(true, is_empty_or_null_string) + { checker .diagnostics .push(Diagnostic::new(PytestFailWithoutMessage, call.func.range()));