Repository: astral-sh/ruff
File: crates/ruff_linter/src/rules/flake8_blind_except/rules/blind_except.rs (Rust)

Code before:
                    _ => false,
                };
                if reraised {
                    self.seen = true;
                }
            }
            Stmt::Try(_) | Stmt::FunctionDef(_) | Stmt::ClassDef(_) => {}
            _ => walk_stmt(self, stmt),
        }
    }
}

/// Returns `true` if the `exc_info` keyword argument is truthy.
fn is_exc_info_enabled(
    method_name: &str,
    arguments: &ast::Arguments,
    semantic: &SemanticModel,
    settings: &LinterSettings,
) -> bool {
    if is_ble001_exc_info_suppression_enabled(settings)
        || matches!(method_name, "error" | "critical")
    {
        arguments.find_keyword("exc_info").is_some_and(|keyword| {
            Truthiness::from_expr(&keyword.value, |id| semantic.has_builtin_binding(id))
                .into_bool()
                .unwrap_or(true) // into_bool() can only return None if contained value is Truthiness::Unknown which can be exception object
        })
    } else {
        false
    }
}

/// A visitor to detect whether the exception was logged.
struct LogExceptionVisitor<'a> {
    semantic: &'a SemanticModel<'a>,
    logger_objects: &'a [String],
    settings: &'a LinterSettings,
    seen: bool,
}

impl<'a> LogExceptionVisitor<'a> {
    /// Create a new [`LogExceptionVisitor`] with the given exception name.
    fn new(
        semantic: &'a SemanticModel<'a>,
        logger_objects: &'a [String],
        settings: &'a LinterSettings,
    ) -> Self {
        Self {
            semantic,
            logger_objects,
            settings,

Review comment (suggestion):
Small nit:

```suggestion
                // Treat `Truthiness::Unknown` as true
                .unwrap_or(true)
```

We could also use this instead, which I saw in some other `into_bool` references. It might convey the meaning slightly better and we could omit the comment:


```suggestion
                != Some(false)
```

Code after:
                    // `raise <name>` and `raise <name> from SomeCause`
                    (Some(name), Some(Expr::Name(ast::ExprName { id, .. })), _) if name == id => {
                        true
                    }
                    _ => false,
                };
                if reraised {
                    self.seen = true;
                }
            }
            Stmt::Try(_) | Stmt::FunctionDef(_) | Stmt::ClassDef(_) => {}
            _ => walk_stmt(self, stmt),
        }
    }
}

/// Returns `true` if the `exc_info` keyword argument is truthy.
fn is_exc_info_enabled(
    method_name: &str,
    arguments: &ast::Arguments,
    semantic: &SemanticModel,
    settings: &LinterSettings,
) -> bool {
    if is_ble001_exc_info_suppression_enabled(settings)
        || matches!(method_name, "error" | "critical")
    {
        arguments.find_keyword("exc_info").is_some_and(|keyword| {
            Truthiness::from_expr(&keyword.value, |id| semantic.has_builtin_binding(id)).into_bool()
                != Some(false)
        })
    } else {
        false
    }
}

/// A visitor to detect whether the exception was logged.
struct LogExceptionVisitor<'a> {
    semantic: &'a SemanticModel<'a>,
    logger_objects: &'a [String],
    settings: &'a LinterSettings,
    seen: bool,
}

impl<'a> LogExceptionVisitor<'a> {
    /// Create a new [`LogExceptionVisitor`] with the given exception name.
    fn new(
        semantic: &'a SemanticModel<'a>,
        logger_objects: &'a [String],
        settings: &'a LinterSettings,
    ) -> Self {
        Self {