# 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` as documented. The stderr difference is exactly the removal of the DeprecationWarning that the rule exists to eliminate; the program's actual output ('str string') is unchanged, confirming functional equivalence.
- Program: minimized from 9 to 3 lines

## Reproducer

```python
import logging
logger = logging.getLogger()
logger.warn('str string')
```

## Commands

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

## Observed

```
stderr before: /w/prog.py:3: DeprecationWarning: The 'warn' method is deprecated, use 'warning' instead
stderr after: str string
```

## Diff applied by the fix

```diff
--- orig.py	2026-10-22 13:29:17.596830587 -0400
+++ fixed.py	2026-10-22 13:29:20.235874669 -0400
@@ -1,3 +1,3 @@
 import logging
 logger = logging.getLogger()
-logger.warn('str string')
+logger.warning('str string')
```

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

The original call to `logger.warn` triggers a deprecation warning because the method is outdated; this warning appears on stderr before any other output. After rewriting to `logger.warning`, the deprecated method is no longer invoked, so the deprecation warning is suppressed. Although both methods log the same message ('str string') to the log output, the absence of the deprecation warning changes the program’s observable behavior—specifically, what is printed to stderr—making the transformation not semantics-preserving under strict behavioral equivalence that includes side effects like warnings.

## Upstream search

Queries: "G010 fix", "ruff G010 warn method", "logging.warn deprecation fix", "Oracle warning method replacement"

- duplicate: https://github.com/astral-sh/ruff/issues/12295
  same rule G010 and same construct logging.Logger.warn being rewritten to warning
- related: https://github.com/astral-sh/ruff/issues/7248
  same flake8-logging rule set but different specific rules
- related: https://github.com/astral-sh/ruff/issues/2186
  same rule G010 alias tracking but not the same defect
- related: https://github.com/astral-sh/ruff/issues/13673
  same G rules category but different logger library loguru
- duplicate: https://github.com/astral-sh/ruff/issues/17219
  explicitly closed as duplicate of issue 12295 about logging.Logger.warn

<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
- [tavily] Warn about error being related to a deprecated rule · Issue #18349 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/18349
- [tavily] Allow to declare modules/calls as deprecated · Issue #10131 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/10131
- [tavily] F401 is not doing the "right" thing with __init__.py · Issue #15858 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/15858
- [tavily] Ruff server not closing with neovim instances - vol 2 · Issue #11545 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/11545

</details>
