From 5792ed15da6e37b9c37dc1960794139338d9916f Mon Sep 17 00:00:00 2001 From: Vasco Schiavo <115561717+VascoSch92@users.noreply.github.com> Date: Sun, 11 May 2025 18:15:15 +0200 Subject: [PATCH] [`ruff`] add fix safety section (`RUF033`) (#17760) This PR adds the fix safety section for rule `RUF033` (https://github.com/astral-sh/ruff/issues/15584 ). --- .../ruff_linter/src/rules/ruff/rules/post_init_default.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/ruff_linter/src/rules/ruff/rules/post_init_default.rs b/crates/ruff_linter/src/rules/ruff/rules/post_init_default.rs index c587a0f7a2..256e650e68 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/post_init_default.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/post_init_default.rs @@ -61,6 +61,12 @@ use super::helpers::{dataclass_kind, DataclassKind}; /// foo = Foo() # Prints '1 2'. /// ``` /// +/// ## Fix safety +/// +/// This fix is always marked as unsafe because, although switching to `InitVar` is usually correct, +/// it is incorrect when the parameter is not intended to be part of the public API or when the value +/// is meant to be shared across all instances. +/// /// ## References /// - [Python documentation: Post-init processing](https://docs.python.org/3/library/dataclasses.html#post-init-processing) /// - [Python documentation: Init-only variables](https://docs.python.org/3/library/dataclasses.html#init-only-variables)