astral-sh / astral-sh/ruff

No error on `logging.Logger.warn` access [G010]

Open
#12,295 2 comments 0 reactions 0 assignees View on GitHub
bug type-inference
Dominant language
Rust
Stars
49.6k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
458

Description

Before creating this issue I searched for:
```
G010
logger warn
logger.warn
```
but could not find previous issue or PR.

Minimal code snippet (`ruff_G010_no_call.py`) that reproduces the bug:
```
"""No G010 on logging.Logger.warn access."""
import logging

logger = logging.getLogger()
warn = logger.warn
warn("Hello, world!")
```

I invoked `ruff` with:
```
$ ruff check ruff_G010_no_call.py --isolated --select G010 --target-version py313
$ ruff check ruff_G010_no_call.py --isolated --select ALL --target-version py313
```
but got no errors.

I expected to get `G010` (https://docs.astral.sh/ruff/rules/logging-warn/) on line `warn = logger.warn`. The code like this is quite wide-spread, here are the results of GitHub search that show code most likely to be invalid in Python 3.13, but that won't be detected with the current version of ruff: https://github.com/search?q=%2F%28%3F-i%29%28logger%7Clogging%29.warn%24%2F+language%3APython&type=code

I installed `ruff` from PyPI first, then from `https://github.com/astral-sh/ruff/archive/refs/heads/main.zip`:
```
$ python3 --version
Python 3.13.0b3
$ ruff --version
ruff 0.5.1
```

As a side note, current stable version of `mypy` does not find this issue either. `mypy` installed from `master` can find this issue though.

Contributor guide

Open the contributing guide

Research direction

Start with ruff_G010_no_call.py and run the reported isolated commands with --select G010. Trace how G010 handles attribute access, then add coverage so `warn = logger.warn` is diagnosed while the existing call behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.