From 106a38f7b2caccf67016fae27228bde17ca6ba21 Mon Sep 17 00:00:00 2001 From: vasco Date: Wed, 14 May 2025 19:36:48 +0200 Subject: [PATCH 1/2] add fix safety section --- .../src/rules/flake8_simplify/rules/ast_ifexp.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs index 9f054ef51e0041..a3a21083942433 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs @@ -27,6 +27,13 @@ use crate::checkers::ast::Checker; /// bool(a) /// ``` /// +/// ## Fix safety +/// +/// This fix is marked as unsafe because it may change the program’s behavior if the condition does not +/// return a proper Boolean. While the fix will try to wrap non-boolean values in a call to bool, +/// custom implementations of comparison functions like `__eq__` can avoid the bool call and still +/// lead to altered behavior. +/// /// ## References /// - [Python documentation: Truth Value Testing](https://docs.python.org/3/library/stdtypes.html#truth-value-testing) #[derive(ViolationMetadata)] From bd2fbe9f13b07d07350e2f30b73d439973eccc5a Mon Sep 17 00:00:00 2001 From: vasco Date: Thu, 15 May 2025 08:14:48 +0200 Subject: [PATCH 2/2] add removing of comments --- crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs index a3a21083942433..afa332011eaa8d 100644 --- a/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs +++ b/crates/ruff_linter/src/rules/flake8_simplify/rules/ast_ifexp.rs @@ -32,7 +32,7 @@ use crate::checkers::ast::Checker; /// This fix is marked as unsafe because it may change the program’s behavior if the condition does not /// return a proper Boolean. While the fix will try to wrap non-boolean values in a call to bool, /// custom implementations of comparison functions like `__eq__` can avoid the bool call and still -/// lead to altered behavior. +/// lead to altered behavior. Moreover, the fix may remove comments. /// /// ## References /// - [Python documentation: Truth Value Testing](https://docs.python.org/3/library/stdtypes.html#truth-value-testing)