# ruff G010: fix changes program behavior

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: ruff ruff 0.17.1
- Rule: G010 (tool labels the fix: unknown, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): intended-change, severity low. The rule rewrites the deprecated `logger.warn` call to `logger.warning`, which the documentation states is functionally equivalent. The observed difference is that the DeprecationWarning emitted by the old call disappears after the fix, which is exactly the semantic change the rule exists to make.
- Program: minimized from 7 to 4 lines

## Reproducer

```python
import logging
logger = logging.getLogger()
name = 'Alice'
logger.warn('Hello {}'.format(name))
```

## Commands

```sh
python3 prog.py
ruff check --preview --isolated --select G010 --fix prog.py
python3 prog.py
```

## Observed

```
stderr before: /w/prog.py:4: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
stderr after: Hello Alice
```

## Diff applied by the fix

```diff
--- orig.py	2026-10-22 13:28:48.918351837 -0400
+++ fixed.py	2026-10-22 13:28:51.539395569 -0400
@@ -1,4 +1,4 @@
 import logging
 logger = logging.getLogger()
 name = 'Alice'
-logger.warn('Hello {}'.format(name))
+logger.warning('Hello {}'.format(name))
```

## Why the rewrite is not equivalent (model draft, verify before use)

The original call to `logger.warn` produces a deprecation warning on standard error because the method is deprecated; this side effect is observable behavior. Replacing it with `logger.warning` eliminates that warning, altering the program’s stderr output while stdout remains unchanged. Since the fix changes what is printed to stderr, it does not preserve the original program’s semantics. A truly semantics-preserving transformation must maintain all observable effects, including warnings. Thus labeling the fix as safe is incorrect when deprecation warnings are considered part of the program’s behavior.

## Upstream search

Queries: "G010 fix", "ruff G010 warn method deprecation", "logging warn call replacement warning", "deprecated warn to warning migration"

- duplicate: https://github.com/astral-sh/ruff/issues/12295
  same rule G010 and same construct: rewriting deprecated `logger.warn` to `logger.warning`
- related: https://github.com/astral-sh/ruff/issues/7248
  same rule family (flake8-logging) but different specific rules and constructs
- related: https://github.com/astral-sh/ruff/issues/2186
  same rule G010 mentioned as alias but different defect class (aliasing vs autofix behavior)
- related: https://github.com/astral-sh/ruff/issues/13673
  same G rule family but different construct (loguru vs stdlib logging)
- related: https://github.com/astral-sh/ruff/issues/17219
  same rule G010 and logging context but different construct (G004 f-string vs G010 warn deprecation)
- related: https://github.com/astral-sh/ruff/issues/15555
  same G rule family (flake8-logging-format) and autofix context but different pattern/construct

<details><summary>All hits</summary>

- [github, open] No error on `logging.Logger.warn` access [G010] — https://github.com/astral-sh/ruff/issues/12295
- [github, open] Implement `flake8-logging` — https://github.com/astral-sh/ruff/issues/7248
- [github, open] Add support for rule aliasing — https://github.com/astral-sh/ruff/issues/2186
- [github, closed] unused-function-argument not silenced by prefixed underscore if variable name is "次" — https://github.com/astral-sh/ruff/issues/28721
- [github, closed] G rules seems not working with loguru. — https://github.com/astral-sh/ruff/issues/13673
- [github, closed] Ord violation panic when fixing file with nightly compiler — https://github.com/astral-sh/ruff/issues/12469
- [github, closed] Pack of fuzzer Autofix/Infinite loop errors [2] — https://github.com/astral-sh/ruff/issues/8402
- [github, closed] Rule RUF027 cause panic — https://github.com/astral-sh/ruff/issues/9895
- [github, closed] Fixed code unformatted — https://github.com/astral-sh/ruff/issues/8619
- [github, closed] Add option to disable preview warnings — https://github.com/astral-sh/ruff/issues/8620
- [tavily] Importing a logger circumvents "logging-f-string (G004)" · Issue #17219 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/17219
- [github, closed] RUF065 should not apply to the combination of `%r` and `repr` — https://github.com/astral-sh/ruff/issues/20583
- [github, closed] Allow to declare modules/calls as deprecated — https://github.com/astral-sh/ruff/issues/10131
- [tavily] Autofix for flake8-logging-format (G) rules · Issue #15555 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/15555
- [github, open] Seeking improved pytest rules, as `flake8-pytest-style` doesn't align with best practices — https://github.com/astral-sh/ruff/issues/8796

</details>
