# 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 is trivial and unrelated to the rule's pattern; the failure is entirely in the tooling environment.
- Program: minimized from 9 to 2 lines

## Reproducer

```python
def gen():
    yield 1
```

## 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 function returns a generator object when called; calling it yields values one at a time via iteration. If the fix incorrectly rewrites this to return the literal value 1 directly (e.g., replacing the generator with a simple return), then invoking the function would produce an integer instead of a generator. Subsequent code expecting to iterate over the result—such as a for‑loop or next() call—would fail with a TypeError because integers are not iterable. Thus the observable behavior changes from producing a sequence of values to either returning a single value or raising an error, breaking semantics.

## Upstream search

Queries: "UP038 fix", "ruff UP038 generator function", "rule UP038 yield expression", "unused import UP038"

- related: https://github.com/astral-sh/ruff/issues/13051
  Existing report is about outdated documentation for UP038 fix safety, not a tool crash on a generator function.
- related: https://github.com/astral-sh/ruff/issues/7871
  Existing report is about UP038 rewriting isinstance checks to slower code, not a tool crash on a generator function.
- related: https://github.com/astral-sh/ruff/issues/18349
  Existing report is about a warning for a deprecated UP038 rule, not a tool crash on a generator function.

<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

</details>
