ruff G010: fix changes program behavior
Hypothesis Nemotron 3 Super predicted to fire fired 1×
When multiple logger-like objects exist (e.g., `access_logger` and `error_logger`), the tool might incorrectly apply the fix based on naming heuristics even if only one is a true logger per `lint.logg
Program
Output
(no stdout) /w/prog.py:4: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
(no stdout) error msg
- fired
- 1 before · 0 after
- runs
- each version twice, same file name, no network
Judge Nemotron 3 Ultra advisory intended-change · low
The rule rewrites the deprecated .warn() method to .warning() as documented. The stderr difference occurs because the DeprecationWarning emitted by the old code disappears after the fix, which is exactly the semantic change the rule intends to make.
Explanation Nemotron 3 Super unverified
The original call to `warn` emits a deprecation warning via Python’s warnings system; replacing it with `warning` suppresses that specific warning because the newer method does not trigger deprecation notices. Since the program’s observable output includes stderr (where the warning appears), removing it changes behavior—what was printed to stderr before (`DeprecationWarning`) is absent after the rewrite, making the transformation not semantics‑preserving under the language’s full execution model, which accounts for all side effects including warnings.
Reproduce
- file
prog.py(the before program)- minimized program
- r1-p001.py
- evidence sheet
- r1-p001.md
- regression fixture
- r1-p001.py the minimized program with a header stating the observed change, for the tool's test suite
python3 prog.py ruff check --preview --isolated --select G010 --fix prog.py python3 prog.py
Upstream search GitHub issues Tavily Nemotron 3 Super + Ultra
G010 fix · ruff G010 logger warn method · logging warning deprecation fix · error_logger.warn to warning
- duplicate astral-sh/ruff/issues/12295 same rule G010 and same construct logging.Logger.warn being incorrectly rewritten to warning
- related astral-sh/ruff/issues/7248 tracks flake8-logging rules including G010 but is a meta-issue not the same defect
- related astral-sh/ruff/issues/2186 discusses rule aliasing for G010 but not the same rewrite defect
- related astral-sh/ruff/issues/13673 mentions G rules not working with loguru but not the same Logger.warn rewrite
- duplicate astral-sh/ruff/issues/17219 explicitly closed as duplicate of issue 12295 about logging.Logger.warn access
- related astral-sh/ruff/issues/21889 BLE001 about logging.warning validation but different rule and construct
Details
- program
- Multiple logger-like objects - heuristic misapplication
- hazard
- When multiple logger-like objects exist (e.g., `access_logger` and `error_logger`), the tool might incorrectly apply the fix based on naming heuristics even if only one is a true logger per `lint.logg
- oracle
stderr before: /w/prog.py:4: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead stderr after: error msg- run
- 2026-10-17T20-24-12-113Z-iye4-ruff-G010
generated program (11 lines) and the fix's diff
--- orig.py 2026-10-17 16:24:27.826896136 -0400 +++ fixed.py 2026-10-17 16:24:28.077895473 -0400 @@ -4,8 +4,8 @@ access_logger = logging.getLogger('access') # Not in lint.logger-objects # Rule should fire on error_logger.warn but NOT on access_logger.warn try: - error_logger.warn('error msg') # Should become .warning - access_logger.warn('access msg') # Should NOT be changed (heuristic overreach) + error_logger.warning('error msg') # Should become .warning + access_logger.warning('access msg') # Should NOT be changed (heuristic overreach) except Exception as e: print(f'Error: {type(e).__name__}: {e}') print('Done')
rule documentation given to the models
# logging-warn (G010)
Derived from the **flake8-logging-format** linter.
Fix is always available.
## What it does
Checks for uses of `logging.warn` and `logging.Logger.warn`.
## Why is this bad?
`logging.warn` and `logging.Logger.warn` are deprecated in favor of
`logging.warning` and `logging.Logger.warning`, which are functionally
equivalent.
## Known problems
This rule detects uses of the `logging` module via a heuristic.
Specifically, it matches against:
- Uses of the `logging` module itself (e.g., `import logging; logging.info(...)`).
- Uses of `flask.current_app.logger` (e.g., `from flask import current_app; current_app.logger.info(...)`).
- Objects whose name starts with `log` or ends with `logger` or `logging`,
when used in the same file in which they are defined (e.g., `logger = logging.getLogger(); logger.info(...)`).
- Imported objects marked as loggers via the [`lint.logger-objects`] setting, which can be
used to enforce these rules against shared logger objects (e.g., `from module import logger; logger.info(...)`,
when [`lint.logger-objects`] is set to `["module.logger"]`).
## Example
```python
import logging
logging.warn("Something happened")
```
Use instead:
```python
import logging
logging.warning("Something happened")
```
## Options
- `lint.logger-objects`
## References
- [Python documentation: `logging.warning`](https://docs.python.org/3/library/logging.html#logging.warning)
- [Python documentation: `logging.Logger.warning`](https://docs.python.org/3/library/logging.html#logging.Logger.warning)