Skip to content

Commit 315fb0f

Browse files
MeGaGiGaGondylwil3
andauthored
[flake8-logging] Add fix safety section to LOG002 (#18840)
## Summary Part of #15584 This adds a `Fix safety` section to [invalid-get-logger-argument (LOG002)](https://docs.astral.sh/ruff/rules/invalid-get-logger-argument/#invalid-get-logger-argument-log002). The fix/lint was introduced in #7399 No reasoning is given on the unsafety in the PR/code Unsafe fix demonstration: [playground](https://play.ruff.rs/e8008cbf-2ef5-4d38-8255-324f90e624cb) ```py import logging logger = logging.getLogger(__file__) ``` --------- Co-authored-by: Dylan <[email protected]>
1 parent bbc26b2 commit 315fb0f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

crates/ruff_linter/src/rules/flake8_logging/rules/invalid_get_logger_argument.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ use crate::{Edit, Fix, FixAvailability, Violation};
3939
/// logger = logging.getLogger(__name__)
4040
/// ```
4141
///
42+
/// ## Fix safety
43+
/// This fix is always unsafe, as changing the arguments to `getLogger` can change the
44+
/// received logger object, and thus program behavior.
45+
///
4246
/// [logging documentation]: https://docs.python.org/3/library/logging.html#logger-objects
4347
#[derive(ViolationMetadata)]
4448
pub(crate) struct InvalidGetLoggerArgument;

0 commit comments

Comments
 (0)