# ruff UP038: tool crashes

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: UP038 (tool labels the fix: unknown)
- Oracle: tool-crash
- Judge (Nemotron 3 Ultra, advisory): program-bug, severity low. The linter crashed because rule UP038 was removed from the codebase and cannot be selected, not because of any rewrite applied to the program. The program itself contains no isinstance or issubclass calls, so the rule would not have matched anything. The observed failure is a tool availability issue, not a semantic change from a fix.
- Program: minimized from 4 to 4 lines

## Reproducer

```python
class Writer:
    def write(self, s): print(s)
with Writer() as w:
    w.write('hello')
```

## Commands

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

## Observed

```
lint crashed: ruff failed
  Cause: Rule `UP038` was removed and cannot be selected.
```

## Diff applied by the fix

```diff

```

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

The original code creates a Writer instance via context manager but does nothing with its return value; __enter__ returns self, yet the variable w binds to that, allowing w.write('hello') to execute. If the fix attempted to remove the with statement entirely—e.g., rewriting to Writer().write('hello')—it would still call write, but the tool crash occurred because UP038 was deleted, so no rewrite was actually applied. Since the diff shows no change, the program’s behavior remains identical; any difference would stem only from a hypothetical unsafe rewrite that was never executed due to the rule’s removal. Thus, no actual behavioral change occurred—the observed failure is a tool issue, not a semantic one. (119 words)

## Upstream search

Queries: "UP038 fix", "ruff UP038 context manager usage", "Writer class __enter__ method call", "with statement resource cleanup pattern"

- related: https://github.com/astral-sh/ruff/issues/13051
  Existing report is about outdated documentation for deprecated rule UP038, not a crash when selecting it.
- related: https://github.com/astral-sh/ruff/issues/7871
  Existing report is about UP038 rewriting isinstance checks incorrectly, not a tool crash on context manager code.
- related: https://github.com/astral-sh/ruff/issues/18349
  Existing report is about warning for deprecated rule UP038, not a crash when the rule is selected.

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

- [github, closed] `UP038` documentation outdated wrt. fix safety — https://github.com/astral-sh/ruff/issues/13051
- [github, closed] UP038 rewrites code to make it slower and more verbose — https://github.com/astral-sh/ruff/issues/7871
- [github, closed] Warn about error being related to a deprecated rule — https://github.com/astral-sh/ruff/issues/18349
- [github, closed] [Bug] [DOC501 & DOC502] Numpy still docstrings with `:exc:` directive for exceptions are falsely flagged — https://github.com/astral-sh/ruff/issues/14609
- [github, closed] `# flake8: noqa` top-of-the-file comment doesn't respect `external` config — https://github.com/astral-sh/ruff/issues/10202
- [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
- [github, closed] Implement pyupgrade — https://github.com/astral-sh/ruff/issues/827
- [github, open] Implement Pylint — https://github.com/astral-sh/ruff/issues/970

</details>
