[flake8-bugbear ] Add fix safety section (B006) (#17652)

## Summary

This PR add the `fix safety` section for rule `B006` in
`mutable_argument_default.rs` for #15584

When applying this rule for fixes, certain changes may alter the
original logical behavior. For example:

before:
```python
def cache(x, storage=[]):
    storage.append(x)
    return storage

print(cache(1))  # [1]
print(cache(2))  # [1, 2]
```

after:
```python
def cache(x, storage=[]):
    storage.append(x)
    return storage

print(cache(1))  # [1]
print(cache(2))  # [2]
```
This commit is contained in:
Hans 2025-05-29 04:27:13 +08:00 committed by GitHub
parent e23d4ea027
commit 16621fa19d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -68,6 +68,12 @@ use crate::{Edit, Fix, FixAvailability, Violation};
/// ## Options
/// - `lint.flake8-bugbear.extend-immutable-calls`
///
/// ## Fix safety
///
/// This fix is marked as unsafe because it replaces the mutable default with `None`
/// and initializes it in the function body, which may not be what the user intended,
/// as described above.
///
/// ## References
/// - [Python documentation: Default Argument Values](https://docs.python.org/3/tutorial/controlflow.html#default-argument-values)
#[derive(ViolationMetadata)]