fixhunt

ruff UP038: tool crashes

tool-crashlabelled unknownprogram-bug · lowno match
Findings / 2026-10-17T21-20-52-142Z-httm-ruff-UP038 / r2-p002ruff 0.17.18 → 5 lines2026-10-17 21:20 UTC

Hypothesis Nemotron 3 Super predicted to fire did not fire

If the isinstance call appears in a lambda or comprehension, moving the union expression may alter evaluation timing if types have side effects (though rare).

Program

before
1class T:
2 def __class_getitem__(cls, item):
3 return super().__class_getitem__(item)
4f = lambda: isinstance(1, (T[int],))
5f()
after
1(no fix applied)

Output

stdout beforeexit 1
(no stdout)
AttributeError: 'super' object has no attribute '__class_getitem__'
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, so no fix was actually applied to the program. The observed difference is a tool execution failure unrelated to the program's semantics or the rewrite itself.

Explanation Nemotron 3 Super unverified

The original program defines class T with `__class_getitem__`, enabling generic subscripting like `T[int]`. The lambda checks if integer 1 is an instance of `(T[int],)`, which evaluates to True because `isinstance` accepts type objects from such expressions. After applying the fix—which does nothing—the program remains unchanged but Ruff crashes due to attempting to use a removed rule (UP038). However, since no actual code transformation occurs, there is no semantic change in behavior; the observed crash is a tool failure, not a difference in program semantics. Thus, the rewritten (identical) program does not behave differently—it either runs successfully or fails due to the tool’s internal error, not altered logic. Any perceived difference stems from tool instability, not semantics preservation failure in the code itself.

Reproduce

file
prog.py (the before program)
minimized program
r2-p002.py
evidence sheet
r2-p002.md
regression fixture
r2-p002.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 removal · lambda isinstance tuple annotation · super class getitem call

no duplicate or related report 0 hits triaged

Details

program
Lambda/comprehension alters evaluation timing
hazard
If the isinstance call appears in a lambda or comprehension, moving the union expression may alter evaluation timing if types have side effects (though rare).
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 (8 lines) and the fix's diff
1class T:
2 def __class_getitem__(cls, item):
3 print(f'T[{item}]')
4 return super().__class_getitem__(item)
5f = lambda: isinstance(1, (T[int],))
6print('before')
7f()
8print('after')
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/