Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flake8-logging] Implement LOG007: ExceptionWithoutExcInfo #7410

Merged
merged 9 commits into from
Sep 18, 2023
Prev Previous commit
Next Next commit
Fix doc, add testcases for logger.exception()
  • Loading branch information
qdegraaf committed Sep 18, 2023
commit b610037b5e0c934e61a638d08bc51da26095cc5e
7 changes: 7 additions & 0 deletions crates/ruff/resources/test/fixtures/flake8_logging/LOG007.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import logging
qdegraaf marked this conversation as resolved.
Show resolved Hide resolved

logger = logging.getLogger(__name__)

logging.exception("foo") # OK
logging.exception("foo", exc_info=False) # LOG007
logging.exception("foo", exc_info=[]) # LOG007
logger.exception("foo") # OK
logger.exception("foo", exc_info=False) # LOG007
logger.exception("foo", exc_info=[]) # LOG007


from logging import exception

exception("foo", exc_info=False) # LOG007
exception("foo", exc_info=True) # OK

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::checkers::ast::Checker;
/// ## Why is this bad?
/// The `exception()` method captures the exception automatically. Disabling this by setting
/// `exc_info=False` is the same as using `error()`, which is clearer and doesn’t need the
/// `exc_info`argument. This rule detects `exception()` calls with an exc_info argument that is
/// `exc_info` argument. This rule detects `exception()` calls with an exc_info argument that is
/// falsy.
///
/// ## Example
Expand Down
Loading