mirror of https://github.com/astral-sh/ruff
[`flake8-logging`] Add fix safety section to `LOG001` (#18841)
Part of #15584 This adds a `Fix safety` section to [direct-logger-instantiation (LOG001)](https://docs.astral.sh/ruff/rules/direct-logger-instantiation/#direct-logger-instantiation-log001). The fix/lint was introduced in #7397 No reasoning is given on the unsafety in the PR/code Unsafe fix demonstration: [playground](https://play.ruff.rs/72e7277e-a9db-4cd9-9afb-2c56ef2db361) ```py import logging logger = logging.Logger(__name__) ``` ## Test Plan <!-- How was it tested? --> N/A, no tests/functionality affected --------- Co-authored-by: Dylan <dylwil3@gmail.com>
This commit is contained in:
parent
b64307f65e
commit
34fd44eb55
|
|
@ -36,6 +36,10 @@ use crate::{Edit, Fix, FixAvailability, Violation};
|
|||
/// logger = logging.getLogger(__name__)
|
||||
/// ```
|
||||
///
|
||||
/// ## Fix safety
|
||||
/// This fix is always unsafe, as changing from `Logger` to `getLogger`
|
||||
/// changes program behavior by will adding the logger to the logging tree.
|
||||
///
|
||||
/// [Logger Objects]: https://docs.python.org/3/library/logging.html#logger-objects
|
||||
#[derive(ViolationMetadata)]
|
||||
pub(crate) struct DirectLoggerInstantiation;
|
||||
|
|
|
|||
Loading…
Reference in New Issue