mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-03 05:13:00 +00:00
[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 <dylwil3@gmail.com>
This commit is contained in:
parent
bbc26b2f11
commit
315fb0f3da
1 changed files with 4 additions and 0 deletions
|
|
@ -39,6 +39,10 @@ use crate::{Edit, Fix, FixAvailability, Violation};
|
||||||
/// logger = logging.getLogger(__name__)
|
/// logger = logging.getLogger(__name__)
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
/// ## Fix safety
|
||||||
|
/// This fix is always unsafe, as changing the arguments to `getLogger` can change the
|
||||||
|
/// received logger object, and thus program behavior.
|
||||||
|
///
|
||||||
/// [logging documentation]: https://docs.python.org/3/library/logging.html#logger-objects
|
/// [logging documentation]: https://docs.python.org/3/library/logging.html#logger-objects
|
||||||
#[derive(ViolationMetadata)]
|
#[derive(ViolationMetadata)]
|
||||||
pub(crate) struct InvalidGetLoggerArgument;
|
pub(crate) struct InvalidGetLoggerArgument;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue