-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed as duplicate of#18665
Labels
bugmypy got something wrongmypy got something wrong
Description
Either both of these should error, or neither of them.
def test1(items: tuple[int, ...]) -> None:
reveal_type(items[1]) # ✅️
reveal_type(items[2]) # ✅️
reveal_type(items[3]) # ✅️
def test2(items: tuple[int, *tuple[int, ...]]) -> None:
reveal_type(items[1]) # ❌️ tuple index out of range
reveal_type(items[2]) # ❌️ tuple index out of range
reveal_type(items[3]) # ❌️ tuple index out of rangehttps://mypy-play.net/?mypy=master&python=3.12&gist=dc9de67cb18ae540cdbb6bc32632eae7
FWIW, only mypy errors here. pyright (strict): no errors, pyrefly no errors, ty: no errors.
Such tuple types can occur naturally, which makes this check prone to false positives, for instance tup=(id, *values), when values is list-like.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong