From 05a2f522069701acff0267547799871014add0a2 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 29 Jan 2024 09:48:40 -0800 Subject: [PATCH] Document `literal-membership` fix safety conditions (#9677) ## Summary This seems safe to me. See https://github.com/astral-sh/ruff/issues/8482#issuecomment-1859299411. ## Test Plan `cargo test` --- .../src/rules/pylint/rules/literal_membership.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/ruff_linter/src/rules/pylint/rules/literal_membership.rs b/crates/ruff_linter/src/rules/pylint/rules/literal_membership.rs index 44dbe31dfa8ef..245de4e538c21 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/literal_membership.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/literal_membership.rs @@ -21,6 +21,12 @@ use crate::checkers::ast::Checker; /// ```python /// 1 in {1, 2, 3} /// ``` +/// +/// ## Fix safety +/// This rule's fix is marked as unsafe, as the use of a `set` literal will +/// error at runtime if the sequence contains unhashable elements (like lists +/// or dictionaries). +/// /// ## References /// - [What’s New In Python 3.2](https://docs.python.org/3/whatsnew/3.2.html#optimizations) #[violation]