From 61c067e28571f87d8726c159e3a18fd2db0c2658 Mon Sep 17 00:00:00 2001 From: hauntsaninja Date: Mon, 1 Jan 2024 16:38:04 -0800 Subject: [PATCH] Document PERF102 fix unsafety Relates to #8482 --- .../src/rules/perflint/rules/incorrect_dict_iterator.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs b/crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs index 829e63e0ddea4..d1f1e6ef9748a 100644 --- a/crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs +++ b/crates/ruff_linter/src/rules/perflint/rules/incorrect_dict_iterator.rs @@ -37,6 +37,12 @@ use crate::checkers::ast::Checker; /// for value in obj.values(): /// print(value) /// ``` +/// +/// ## Fix safety +/// The fix does not perform any type analysis. The fix will be incorrect if the +/// object in question does not duck-type as a mapping, e.g. because it is +/// missing `.keys()` or `.values()` or because those methods behave differently +/// than they do on mappings. #[violation] pub struct IncorrectDictIterator { subset: DictSubset,