Skip to content

Commit

Permalink
[flake8-blind-except] Document exceptions to blind-except rule (#…
Browse files Browse the repository at this point in the history
…9580)

Closes #9571.
  • Loading branch information
charliermarsh authored Jan 19, 2024
1 parent 47ad7b4 commit df617c3
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 df617c3

Please sign in to comment.