Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
InSyncWithFoo committed Jan 23, 2025
1 parent 6b57e3a commit 1bb4bab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 1 addition & 5 deletions crates/ruff_linter/src/checkers/ast/analyze/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,11 +947,7 @@ pub(crate) fn expression(expr: &Expr, checker: &mut Checker) {
}
}
if checker.enabled(Rule::PytestUnittestRaisesAssertion) {
if let Some(diagnostic) =
flake8_pytest_style::rules::unittest_raises_assertion_call(checker, call)
{
checker.diagnostics.push(diagnostic);
}
flake8_pytest_style::rules::unittest_raises_assertion_call(checker, call);
}
if checker.enabled(Rule::SubprocessPopenPreexecFn) {
pylint::rules::subprocess_popen_preexec_fn(checker, call);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,21 +366,20 @@ impl Violation for PytestUnittestRaisesAssertion {
}

/// PT027
pub(crate) fn unittest_raises_assertion_call(
checker: &Checker,
call: &ast::ExprCall,
) -> Option<Diagnostic> {
pub(crate) fn unittest_raises_assertion_call(checker: &mut Checker, call: &ast::ExprCall) {
// Bindings in `with` statements are handled by `unittest_raises_assertion_with`.
if let Stmt::With(ast::StmtWith { items, .. }) = checker.semantic().current_statement() {
if items
.iter()
.any(|item| item.context_expr.range() == call.range && item.optional_vars.is_some())
{
return None;
return;
}
}

unittest_raises_assertion(call, [], checker)
if let Some(diagnostic) = unittest_raises_assertion(call, [], checker) {
checker.diagnostics.push(diagnostic);
}
}

/// PT027
Expand Down

0 comments on commit 1bb4bab

Please sign in to comment.