# 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 .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.
- Program: minimized from 11 to 6 lines

## Reproducer

```python
import logging
error_logger = logging.getLogger('error')
try:
    error_logger.warn('error msg')   # Should become .warning
except Exception as e:
    print(f'Error: {type(e).__name__}: {e}')
```

## 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: error msg
```

## Diff applied by the fix

```diff
--- orig.py	2026-10-22 13:28:28.633013537 -0400
+++ fixed.py	2026-10-22 13:28:31.255057249 -0400
@@ -1,6 +1,6 @@
 import logging
 error_logger = logging.getLogger('error')
 try:
-    error_logger.warn('error msg')   # Should become .warning
+    error_logger.warning('error msg')   # Should become .warning
 except Exception as e:
     print(f'Error: {type(e).__name__}: {e}')
```

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

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.

## Upstream search

Queries: "G010 fix", "ruff G010 logger warn method", "logging warning deprecation fix", "error_logger.warn to warning"

- duplicate: https://github.com/astral-sh/ruff/issues/12295
  same rule G010 and same construct logging.Logger.warn being incorrectly rewritten to warning
- related: https://github.com/astral-sh/ruff/issues/7248
  tracks flake8-logging rules including G010 but is a meta-issue not the same defect
- related: https://github.com/astral-sh/ruff/issues/2186
  discusses rule aliasing for G010 but not the same rewrite defect
- related: https://github.com/astral-sh/ruff/issues/13673
  mentions G rules not working with loguru but not the same Logger.warn rewrite
- duplicate: https://github.com/astral-sh/ruff/issues/17219
  explicitly closed as duplicate of issue 12295 about logging.Logger.warn access
- related: https://github.com/astral-sh/ruff/issues/21889
  BLE001 about logging.warning validation but different rule and 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
- [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] 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] Allow to declare modules/calls as deprecated · Issue #10131 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/10131
- [tavily] Ruff server not closing with neovim instances - vol 2 · Issue #11545 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/11545
- [tavily] BLE001 (blind-except): false positive when logging via `warning` · Issue #21889 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/21889
- [tavily] Feature request: Support a "warning" level for linting · Issue #1256 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/1256
- [tavily] [formatter] Warn when markdown files are skipped due to preview being disabled by chinar-amrutkar · Pull Request #24150 · astral-sh/ruff · GitHub — https://redirect.github.com/astral-sh/ruff/pull/24150
- [tavily] Feature request: Make *any* unknown rule code in "ignore" setting a warning, not an error · Issue #14443 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/14443
- [tavily] Can "Unknown rule selector" be a warning, rather than an error? · Issue #5159 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/5159
- [tavily] Ignoring `RUF102` does not work · Issue #23267 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/23267
- [tavily] Adopt Rust 1.97 integer APIs and Cargo warning policy by charliermarsh · Pull Request #29048 · astral-sh/ruff · GitHub — https://redirect.github.com/astral-sh/ruff/pull/29048
- [tavily] SIM102 Warning when checking value returned from walrus operator · Issue #13024 · astral-sh/ruff · GitHub — https://github.com/astral-sh/ruff/issues/13024

</details>
