[ruff] add fix safety section (RUF005) (#17484)

The PR add the `fix safety` section for rule `RUF005` (#15584 ).

---------

Co-authored-by: Dylan <dylwil3@gmail.com>
This commit is contained in:
Vasco Schiavo 2025-04-26 23:43:02 +02:00 committed by GitHub
parent 64ba39a385
commit b578a828ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,6 +33,12 @@ use crate::fix::snippet::SourceCodeSnippet;
/// bar = [1, *foo, 5, 6]
/// ```
///
/// ## Fix safety
///
/// The fix is always marked as unsafe because the `+` operator uses the `__add__` magic method and
/// `*`-unpacking uses the `__iter__` magic method. Both of these could have custom
/// implementations, causing the fix to change program behaviour.
///
/// ## References
/// - [PEP 448 Additional Unpacking Generalizations](https://peps.python.org/pep-0448/)
/// - [Python documentation: Sequence Types — `list`, `tuple`, `range`](https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range)