From 4e335011153ba570adf14f49e231e11427cc214e Mon Sep 17 00:00:00 2001 From: Rahul Sahoo Date: Sat, 27 Sep 2025 19:20:51 +0530 Subject: [PATCH] Fixed documentation for try_consider_else (#20587) ## 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. --- .../src/rules/tryceratops/rules/try_consider_else.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ruff_linter/src/rules/tryceratops/rules/try_consider_else.rs b/crates/ruff_linter/src/rules/tryceratops/rules/try_consider_else.rs index feb5b7eb6c..cbd24bf61e 100644 --- a/crates/ruff_linter/src/rules/tryceratops/rules/try_consider_else.rs +++ b/crates/ruff_linter/src/rules/tryceratops/rules/try_consider_else.rs @@ -29,6 +29,7 @@ use crate::checkers::ast::Checker; /// return rec /// except ZeroDivisionError: /// logging.exception("Exception occurred") +/// raise /// ``` /// /// Use instead: @@ -41,6 +42,7 @@ use crate::checkers::ast::Checker; /// rec = 1 / n /// except ZeroDivisionError: /// logging.exception("Exception occurred") +/// raise /// else: /// print(f"reciprocal of {n} is {rec}") /// return rec