Skip to content

Commit

Permalink
Document exceptions to blind-except rule
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jan 19, 2024
1 parent b3a6f0c commit 4b15497
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,25 @@ use crate::checkers::ast::Checker;
/// ...
/// ```
///
/// Exceptions that are re-raised will _not_ be flagged, as they're expected to
/// be caught elsewhere:
/// ```python
/// try:
/// foo()
/// except BaseException:
/// raise
/// ```
///
/// Exceptions that are logged via `logging.exception()` or `logging.error()`
/// with `exc_info` enabled will _not_ be flagged, as this is a common pattern
/// for propagating exception traces:
/// ```python
/// try:
/// foo()
/// except BaseException:
/// logging.exception("Something went wrong")
/// ```
///
/// ## References
/// - [Python documentation: The `try` statement](https://docs.python.org/3/reference/compound_stmts.html#the-try-statement)
/// - [Python documentation: Exception hierarchy](https://docs.python.org/3/library/exceptions.html#exception-hierarchy)
Expand Down

0 comments on commit 4b15497

Please sign in to comment.