From a7a06474b72e5a1b67c85d8b070f4f8dc0972536 Mon Sep 17 00:00:00 2001 From: weartist Date: Thu, 17 Apr 2025 16:21:33 +0800 Subject: [PATCH 1/2] add fix safety section to docs --- .../src/rules/pyupgrade/rules/outdated_version_block.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs index 969220eb4481e..6a21b67cab31d 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs @@ -44,6 +44,11 @@ use ruff_python_ast::PythonVersion; /// ## Options /// - `target-version` /// +/// ## Fix safety +/// This rule's fix is marked as unsafe because it will remove all code, +/// comments, and annotations within unreachable version blocks—even if +/// they are never executed at runtime. +/// /// ## References /// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info) #[derive(ViolationMetadata)] From f6a1052f68abfd68062be28b3ffd140b38c56ca4 Mon Sep 17 00:00:00 2001 From: weartist Date: Fri, 18 Apr 2025 09:54:27 +0800 Subject: [PATCH 2/2] adjust comment --- .../src/rules/pyupgrade/rules/outdated_version_block.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs b/crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs index 6a21b67cab31d..bcae8b3de3ddd 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs +++ b/crates/ruff_linter/src/rules/pyupgrade/rules/outdated_version_block.rs @@ -46,8 +46,7 @@ use ruff_python_ast::PythonVersion; /// /// ## Fix safety /// This rule's fix is marked as unsafe because it will remove all code, -/// comments, and annotations within unreachable version blocks—even if -/// they are never executed at runtime. +/// comments, and annotations within unreachable version blocks. /// /// ## References /// - [Python documentation: `sys.version_info`](https://docs.python.org/3/library/sys.html#sys.version_info)