[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 ).
This commit is contained in:
Vasco Schiavo 2025-05-11 18:15:15 +02:00 committed by GitHub
parent 8845a13efb
commit 5792ed15da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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)