diff --git a/crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG014_0.py b/crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG014_0.py index b3dc5f79bb..5eb188a987 100644 --- a/crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG014_0.py +++ b/crates/ruff_linter/resources/test/fixtures/flake8_logging/LOG014_0.py @@ -32,6 +32,12 @@ except ...: ### No errors +logging.info("", exc_info=ValueError()) +logger.info("", exc_info=ValueError()) + +logging.info("", exc_info=(exc_type, exc_value, exc_traceback)) +logger.info("", exc_info=(exc_type, exc_value, exc_traceback)) + logging.info("", exc_info=a) logger.info("", exc_info=a) diff --git a/crates/ruff_linter/src/rules/flake8_logging/rules/exc_info_outside_except_handler.rs b/crates/ruff_linter/src/rules/flake8_logging/rules/exc_info_outside_except_handler.rs index 9b62775fa0..1daf37dbb2 100644 --- a/crates/ruff_linter/src/rules/flake8_logging/rules/exc_info_outside_except_handler.rs +++ b/crates/ruff_linter/src/rules/flake8_logging/rules/exc_info_outside_except_handler.rs @@ -98,6 +98,10 @@ pub(crate) fn exc_info_outside_except_handler(checker: &Checker, call: &ExprCall return; }; + if !exc_info.value.is_literal_expr() { + return; + } + let truthiness = Truthiness::from_expr(&exc_info.value, |id| semantic.has_builtin_binding(id)); if truthiness.into_bool() != Some(true) {