Closed as not planned
Description
With at least mypy 1.13.0, the false negative can be reproduced with:
from collections.abc import Sequence
from typing import TypeAlias
class Scalar: ...
Vector: TypeAlias = Sequence[Scalar]
Tensor: TypeAlias = Vector | Sequence["Tensor"]
accepted_vector: Vector = [Scalar()] # true negative
rejected_vector: Vector = "duck" # true positive: ducks aren't vectors
accepted_tensor: Tensor = [[[Scalar()]]] # true negative
rejected_tensor1: Tensor = object() # true positive: objects aren't tensors
rejected_tensor2: Tensor = "duck" # false negative: ducks are tensors...?
- mypy-play
- pyright-play (works as expected)
originally posted in #731 (comment)