ty icon indicating copy to clipboard operation
ty copied to clipboard

Fix `Todo` type inferred when subscripting an intersection

Open AlexWaygood opened this issue 1 week ago • 0 comments

from typing import Sequence

class C: ...

def f(x: Sequence[int]):
    if isinstance(x, C):
        reveal_type(x[0])  # revealed: @Todo

We should infer int there (and, same as our current behaviour, we should not emit a diagnostic).

This was previously attempted in https://github.com/astral-sh/ruff/pull/18846 but then reverted in https://github.com/astral-sh/ruff/pull/18920

AlexWaygood avatar Dec 18 '25 14:12 AlexWaygood