-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working
Description
Describe the bug
Unpacking a tuple and packing to another tuple seem to mess up the typing. It is losing the tuple length information, and seems to mess up the order, too: or why is *i, 2 (2 at the end) inferred as tuple[Literal[2], *tuple[int, ...]] (2 at the front)?
Code or Screenshots
my_dict: dict[tuple[int, int], int] = {}
def foo(i: tuple[int]) -> None:
my_dict[*i, 2] = 3
foo((1,))
assert my_dict == {(1, 2): 3}gives
bug.py
bug.py:4:5 - error: Argument of type "tuple[Literal[2], *tuple[int, ...]]" cannot be assigned to parameter "key" of type "tuple[int, int]" in function "__setitem__"
"tuple[Literal[2], *tuple[int, ...]]" is not assignable to "tuple[int, int]"
Tuple size mismatch; expected 2 but received indeterminate (reportArgumentType)
1 error, 0 warnings, 0 informations
VS Code extension or command-line
Python pyright v1.1.403
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working