mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 02:38:25 +00:00
Allow capitalized names for logger candidate heuristic match (#6356)
Closes https://github.com/astral-sh/ruff/issues/6353.
This commit is contained in:
parent
78a370303b
commit
d788957ec4
3 changed files with 19 additions and 1 deletions
|
@ -3,3 +3,6 @@ import logging
|
|||
name = "world"
|
||||
logging.info(f"Hello {name}")
|
||||
logging.log(logging.INFO, f"Hello {name}")
|
||||
|
||||
_LOGGER = logging.getLogger()
|
||||
_LOGGER.info(f"{__name__}")
|
||||
|
|
|
@ -15,6 +15,15 @@ G004.py:5:27: G004 Logging statement uses f-string
|
|||
4 | logging.info(f"Hello {name}")
|
||||
5 | logging.log(logging.INFO, f"Hello {name}")
|
||||
| ^^^^^^^^^^^^^^^ G004
|
||||
6 |
|
||||
7 | _LOGGER = logging.getLogger()
|
||||
|
|
||||
|
||||
G004.py:8:14: G004 Logging statement uses f-string
|
||||
|
|
||||
7 | _LOGGER = logging.getLogger()
|
||||
8 | _LOGGER.info(f"{__name__}")
|
||||
| ^^^^^^^^^^^^^ G004
|
||||
|
|
||||
|
||||
|
||||
|
|
|
@ -49,7 +49,13 @@ pub fn is_logger_candidate(
|
|||
// logger names.
|
||||
if let Some(call_path) = collect_call_path(value) {
|
||||
if let Some(tail) = call_path.last() {
|
||||
if tail.starts_with("log") || tail.ends_with("logger") || tail.ends_with("logging") {
|
||||
if tail.starts_with("log")
|
||||
|| tail.ends_with("logger")
|
||||
|| tail.ends_with("logging")
|
||||
|| tail.starts_with("LOG")
|
||||
|| tail.ends_with("LOGGER")
|
||||
|| tail.ends_with("LOGGING")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue