From caf48f4bfc54bb587342bf794a4f5167d855f529 Mon Sep 17 00:00:00 2001 From: Dan Parizher <105245560+danparizher@users.noreply.github.com> Date: Wed, 1 Oct 2025 13:58:24 -0400 Subject: [PATCH] [`pylint`] Clarify fix safety to include left-hand hashability (`PLR6201`) (#20518) ## Summary Fixes #20510 --- .../src/rules/pylint/rules/literal_membership.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 2130cd29cf..f8a2d91752 100644 --- a/crates/ruff_linter/src/rules/pylint/rules/literal_membership.rs +++ b/crates/ruff_linter/src/rules/pylint/rules/literal_membership.rs @@ -25,9 +25,11 @@ use crate::{AlwaysFixableViolation, Edit, Fix}; /// /// ## 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). While Ruff will attempt to infer the hashability of the -/// elements, it may not always be able to do so. +/// error at runtime if either the element being tested for membership (the +/// left-hand side) or any element of the sequence (the right-hand side) +/// is unhashable (like lists or dictionaries). While Ruff will attempt to +/// infer the hashability of both sides and skip the fix when it can determine +/// that either side is unhashable, it may not always be able to do so. /// /// ## References /// - [What’s New In Python 3.2](https://docs.python.org/3/whatsnew/3.2.html#optimizations)