Skip to content

Fix Todo type inferred when subscripting an intersection #2072

@AlexWaygood

Description

@AlexWaygood
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 astral-sh/ruff#18846 but then reverted in astral-sh/ruff#18920

Metadata

Metadata

Assignees

Labels

typing semanticstyping-module features, spec compliance, etc

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions