# 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 configuration or version mismatch, not a semantic change from a fix.
- Program: minimized from 5 to 2 lines

## Reproducer

```python
if False:
    from typing import List as RuntimeList
```

## 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 program defines a conditional import that never executes because its guard is False; thus no name RuntimeList is bound in the module’s namespace. The attempted rewrite does nothing—it leaves the dead code unchanged—but Ruff then crashes because it tries to apply a rule (UP038) that has been removed, so the linter fails before any transformation can occur. Since the tool aborts, the program is not actually rewritten, yet the user observes a failure where none should happen if the rule were applicable. The mismatch arises not from a semantic change in the code but from the tool’s internal state: selecting a non‑existent rule causes a crash, preventing any intended fix from being applied and making the lint process behave incorrectly. This discrepancy between expected safe fixing and actual tool failure explains why the situation is labeled unsafe.

## Upstream search

Queries: "UP038 fix", "ruff UP038 unused alias", "typing import alias removal crash", "unused imported name detection"

- related: https://github.com/astral-sh/ruff/issues/13051
  Existing report is about UP038 documentation being outdated regarding fix safety, not about the rule being removed and causing a crash when selected.
- related: https://github.com/astral-sh/ruff/issues/7871
  Existing report is about UP038 rewriting code to be slower and more verbose, not about the rule being removed and causing a crash when selected.
- duplicate: https://github.com/astral-sh/ruff/issues/18349
  Existing report describes the same defect: selecting deprecated/removed rule UP038 causes an error/crash instead of a proper warning.

<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] Add autofix that adds `from __future__ import annotations` only when it would be useful — https://github.com/astral-sh/ruff/issues/18502
- [github, open] Meta issue: plugin system — https://github.com/astral-sh/ruff/issues/283
- [github, closed] `extend-select = ["I"]` from pyproject.toml not honored for tests in very specific circumstances — https://github.com/astral-sh/ruff/issues/12453

</details>
