[`pyupgrade`] Add fix safety section to docs (`UP029`) (#17490)

## Summary

Add `fix safety` section to `UP029: unnecessary_builtin_import.rs`, for
#15584
This commit is contained in:
Hans 2025-08-29 21:55:19 +08:00 committed by GitHub
parent 8a6db4f257
commit c2d7c673ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 0 deletions

View File

@ -27,6 +27,21 @@ use crate::{AlwaysFixableViolation, Fix};
/// str(1)
/// ```
///
/// ## Fix safety
/// This fix is marked as unsafe because removing the import
/// may change program behavior. For example, in the following
/// situation:
///
/// ```python
/// def str(x):
/// return x
///
///
/// from builtins import str
///
/// str(1) # `"1"` with the import, `1` without
/// ```
///
/// ## References
/// - [Python documentation: The Python Standard Library](https://docs.python.org/3/library/index.html)
#[derive(ViolationMetadata)]