diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_lookup.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_lookup.rs index f9806190de..e3e7a41b63 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_lookup.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/if_else_block_instead_of_dict_lookup.rs @@ -18,17 +18,22 @@ use crate::checkers::ast::Checker; /// /// ## Example /// ```python -/// if x == 1: -/// return "Hello" -/// elif x == 2: -/// return "Goodbye" -/// else: -/// return "Goodnight" +/// def find_phrase(x): +/// if x == 1: +/// return "Hello" +/// elif x == 2: +/// return "Goodbye" +/// elif x == 3: +/// return "Good morning" +/// else: +/// return "Goodnight" /// ``` /// /// Use instead: /// ```python -/// return {1: "Hello", 2: "Goodbye"}.get(x, "Goodnight") +/// def find_phrase(x): +/// phrases = {1: "Hello", 2: "Goodye", 3: "Good morning"} +/// return phrases.get(x, "Goodnight") /// ``` #[derive(ViolationMetadata)] pub(crate) struct IfElseBlockInsteadOfDictLookup;