mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
[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:
parent
e23d4ea027
commit
16621fa19d
1 changed files with 6 additions and 0 deletions
|
@ -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)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue