fixhunt

ruff UP038: tool crashes

tool-crashlabelled unknownprogram-bug · lowduplicate
Findings / 2026-10-17T21-20-52-142Z-httm-ruff-UP038 / r1-p003ruff 0.17.17 → 4 lines2026-10-17 21:20 UTC

Hypothesis Nemotron 3 Super predicted not to fire did not fire

isinstance(x, ('MyClass', int)) contains a string forward reference; rewriting to 'MyClass' | int is invalid because strings cannot be used with | in isinstance.

Program

before
1try:
2 print('Before:', result)
3except Exception as e:
4 print('Before error:', type(e).__name__, str(e))
after
1(no fix applied)

Output

stdout beforeexit 0
Before error: NameError name 'result' is not defined
stdout afternot run
(not run)
fired
0 before · 0 after
runs
each version twice, same file name, no network

Judge Nemotron 3 Ultra advisory program-bug · 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 was never transformed, so there is no semantic difference to evaluate.

Explanation Nemotron 3 Super unverified

The diff shows no change to the source code; however, because rule UP038 has been removed from Ruff, attempting to apply its fix causes the linter to crash before any transformation occurs. Since no actual rewrite is performed, there is no altered program behavior to compare—the observed failure is solely due to the tool’s inability to execute the rule, not a semantics‑preserving or altering code change. Thus, the explanation of differing behavior does not apply here; the issue is a tool failure, not a semantic difference in the program.

Reproduce

file
prog.py (the before program)
minimized program
r1-p003.py
evidence sheet
r1-p003.md
regression fixture
r1-p003.py the minimized program with a header stating the observed change, for the tool's test suite
python3 prog.py
ruff check --preview --isolated --select UP038 --fix prog.py
python3 prog.py

Upstream search GitHub issues Tavily Nemotron 3 Super + Ultra

UP038 fix · ruff UP038 try except · rule UP038 exception handling · UP038 lint crash removal

  • related astral-sh/ruff/issues/13051 Existing report is about outdated documentation for deprecated rule UP038, not a tool crash when selecting it.
  • related astral-sh/ruff/issues/7871 Existing report is about UP038 producing slower rewrites on isinstance tuples, not a crash when the rule is selected.
  • duplicate astral-sh/ruff/issues/18349 Existing report describes the same crash: selecting deprecated rule UP038 causes a tool crash because the rule was removed.

Details

program
Forward Reference as String in Tuple
hazard
isinstance(x, ('MyClass', int)) contains a string forward reference; rewriting to 'MyClass' | int is invalid because strings cannot be used with | in isinstance.
oracle
lint crashed: ruff failed Cause: Rule `UP038` was removed and cannot be selected.
run
2026-10-17T21-20-52-142Z-httm-ruff-UP038
generated program (7 lines) and the fix's diff
1class MyClass: pass
2x = MyClass()
3try:
4 result = isinstance(x, ('MyClass', int))
5 print('Before:', result)
6except Exception as e:
7 print('Before error:', type(e).__name__, str(e))
rule documentation given to the models
# non-pep604-isinstance (UP038)

Derived from the **pyupgrade** linter.

Fix is always available.

## Removed
This rule was removed as using [PEP 604] syntax in `isinstance` and `issubclass` calls
isn't recommended practice, and it incorrectly suggests that other typing syntaxes like [PEP 695]
would be supported by `isinstance` and `issubclass`. Using the [PEP 604] syntax
is also slightly slower.

## What it does
Checks for uses of `isinstance` and `issubclass` that take a tuple
of types for comparison.

## Why is this bad?
Since Python 3.10, `isinstance` and `issubclass` can be passed a
`|`-separated union of types, which is consistent
with the union operator introduced in [PEP 604].

Note that this results in slower code. Ignore this rule if the
performance of an `isinstance` or `issubclass` check is a
concern, e.g., in a hot loop.

## Example
```python
isinstance(x, (int, float))
```

Use instead:
```python
isinstance(x, int | float)
```

## Options
- `target-version`

## References
- [Python documentation: `isinstance`](https://docs.python.org/3/library/functions.html#isinstance)
- [Python documentation: `issubclass`](https://docs.python.org/3/library/functions.html#issubclass)

[PEP 604]: https://peps.python.org/pep-0604/
[PEP 695]: https://peps.python.org/pep-0695/