ruff UP038: tool crashes
Hypothesis Nemotron 3 Super predicted to fire did not fire
When the tuple includes a generic alias like List[int], the rewrite to List[int] | ... may be invalid at runtime if Python version < 3.9 due to missing __or__ support.
Program
Output
(no stdout) TypeError: Subscripted generics cannot be used with class and instance checks
(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 source code. The observed difference is a tool execution failure unrelated to the rewrite semantics.
Explanation Nemotron 3 Super unverified
The original code checks if x is an instance of a tuple containing the type annotation List[int]; however, due to type erasure, isinstance with generic types like List[int] always returns False at runtime because the type parameter int is not available. The attempted rewrite likely tried to simplify or remove the check incorrectly—perhaps by replacing it with a direct isinstance against list—or assumed the generic could be evaluated, which changes the behavior: the original expression evaluates to False (since List[int] erases to list but isinstance still fails), while an incorrect rewrite might yield True or raise an error, thus altering program semantics. Since the rule was removed, no valid fix exists, and any such transformation would be unsafe.
Reproduce
- file
prog.py(the before program)- minimized program
- r2-p001.py
- evidence sheet
- r2-p001.md
- regression fixture
- r2-p001.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 isinstance tuple type annotation · typing List isinstance crash removal · rule UP038 deprecated isinstance fix
- related astral-sh/ruff/issues/13051 Existing report is about outdated documentation for deprecated rule UP038, not a crash when selecting the removed rule.
- related astral-sh/ruff/issues/7871 Existing report is about UP038 rewriting isinstance checks to slower code, not a crash due to rule removal.
- related astral-sh/ruff/issues/18349 Existing report is about warning for deprecated rule UP038, not a crash when the removed rule is selected.
Details
- program
- Generic alias __or__ missing in Python < 3.9
- hazard
- When the tuple includes a generic alias like List[int], the rewrite to List[int] | ... may be invalid at runtime if Python version < 3.9 due to missing __or__ support.
- 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 (4 lines) and the fix's diff
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/