From fd3fc34a9e5115659c3806f736fef8e7404a9daa Mon Sep 17 00:00:00 2001 From: Hans Date: Sat, 19 Apr 2025 02:27:40 +0800 Subject: [PATCH] [`pyflakes`] Add fix safety section to docs (`F601`, `F602`) (#17440) ## Summary add fix safety section to repeated_keys_docs, for #15584 --------- Co-authored-by: Brent Westbrook --- .../src/rules/pyflakes/rules/repeated_keys.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/repeated_keys.rs b/crates/ruff_linter/src/rules/pyflakes/rules/repeated_keys.rs index f29d1dd339..ac71ff477d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/repeated_keys.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/repeated_keys.rs @@ -40,6 +40,12 @@ use crate::registry::Rule; /// foo["baz"] # 2 /// ``` /// +/// ## Fix safety +/// +/// This rule's fix is marked as unsafe because removing a repeated dictionary key +/// may delete comments that are attached to the removed key-value pair. This can also change +/// the program's behavior if the value expressions have side effects. +/// /// ## References /// - [Python documentation: Dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) #[derive(ViolationMetadata)] @@ -106,6 +112,12 @@ impl Violation for MultiValueRepeatedKeyLiteral { /// foo[baz] # 2 /// ``` /// +/// ## Fix safety +/// +/// This rule's fix is marked as unsafe because removing a repeated dictionary key +/// may delete comments that are attached to the removed key-value pair. This can also change +/// the program's behavior if the value expressions have side effects. +/// /// ## References /// - [Python documentation: Dictionaries](https://docs.python.org/3/tutorial/datastructures.html#dictionaries) #[derive(ViolationMetadata)]