Skip to content

Commit

Permalink
Refactoring 2
Browse files Browse the repository at this point in the history
  • Loading branch information
InSyncWithFoo committed Jan 23, 2025
1 parent 40a761b commit 9b8085f
Show file tree
Hide file tree
Showing 2 changed files with 5 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 @@ -940,11 +940,7 @@ pub(crate) fn expression(expr: &Expr, checker: &mut Checker) {
flake8_pytest_style::rules::parametrize(checker, call);
}
if checker.enabled(Rule::PytestUnittestAssertion) {
if let Some(diagnostic) = flake8_pytest_style::rules::unittest_assertion(
checker, expr, func, args, keywords,
) {
checker.diagnostics.push(diagnostic);
}
flake8_pytest_style::rules::unittest_assertion(checker, expr, func, args, keywords);
}
if checker.enabled(Rule::PytestUnittestRaisesAssertion) {
flake8_pytest_style::rules::unittest_raises_assertion_call(checker, call);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ fn check_assert_in_except(name: &str, body: &[Stmt]) -> Vec<Diagnostic> {

/// PT009
pub(crate) fn unittest_assertion(
checker: &Checker,
checker: &mut Checker,
expr: &Expr,
func: &Expr,
args: &[Expr],
keywords: &[Keyword],
) -> Option<Diagnostic> {
) {
match func {
Expr::Attribute(ast::ExprAttribute { attr, .. }) => {
if let Ok(unittest_assert) = UnittestAssert::try_from(attr.as_str()) {
Expand Down Expand Up @@ -302,12 +302,10 @@ pub(crate) fn unittest_assertion(
)));
}
}
Some(diagnostic)
} else {
None
checker.diagnostics.push(diagnostic);
}
}
_ => None,
_ => {}
}
}

Expand Down

0 comments on commit 9b8085f

Please sign in to comment.