Skip to content

Commit df617c3

Browse files
[flake8-blind-except] Document exceptions to blind-except rule (#9580)
Closes #9571.
1 parent 47ad7b4 commit df617c3

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

crates/ruff_linter/src/rules/flake8_blind_except/rules/blind_except.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,25 @@ use crate::checkers::ast::Checker;
3434
/// ...
3535
/// ```
3636
///
37+
/// Exceptions that are re-raised will _not_ be flagged, as they're expected to
38+
/// be caught elsewhere:
39+
/// ```python
40+
/// try:
41+
/// foo()
42+
/// except BaseException:
43+
/// raise
44+
/// ```
45+
///
46+
/// Exceptions that are logged via `logging.exception()` or `logging.error()`
47+
/// with `exc_info` enabled will _not_ be flagged, as this is a common pattern
48+
/// for propagating exception traces:
49+
/// ```python
50+
/// try:
51+
/// foo()
52+
/// except BaseException:
53+
/// logging.exception("Something went wrong")
54+
/// ```
55+
///
3756
/// ## References
3857
/// - [Python documentation: The `try` statement](https://docs.python.org/3/reference/compound_stmts.html#the-try-statement)
3958
/// - [Python documentation: Exception hierarchy](https://docs.python.org/3/library/exceptions.html#exception-hierarchy)

0 commit comments

Comments
 (0)