Skip to content

Commit 4e33501

Browse files
authored
Fixed documentation for try_consider_else (#20587)
<!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary This PR addresses #20570 . In the example, the correct usage had a bug/issue where in the except block after logging exception, None was getting returned, which made the linters flag out the code. So adding an empty raise solves the issue. ## Test Plan Tested it by building the doc locally.
1 parent 6b3c493 commit 4e33501

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

crates/ruff_linter/src/rules/tryceratops/rules/try_consider_else.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::checkers::ast::Checker;
2929
/// return rec
3030
/// except ZeroDivisionError:
3131
/// logging.exception("Exception occurred")
32+
/// raise
3233
/// ```
3334
///
3435
/// Use instead:
@@ -41,6 +42,7 @@ use crate::checkers::ast::Checker;
4142
/// rec = 1 / n
4243
/// except ZeroDivisionError:
4344
/// logging.exception("Exception occurred")
45+
/// raise
4446
/// else:
4547
/// print(f"reciprocal of {n} is {rec}")
4648
/// return rec

0 commit comments

Comments
 (0)