-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved type inference logic for tuple expressions that contain unpa…
…cked tuples.
- Loading branch information
1 parent
f5916b7
commit b65928c
Showing
3 changed files
with
41 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This sample tests type inference for tuples that contain unpack | ||
# operators. | ||
|
||
from typing import Literal | ||
|
||
|
||
def func1(a: int, *args: int): | ||
v1 = (a, *args) | ||
t1: Literal["tuple[int, ...]"] = reveal_type(v1) | ||
|
||
|
||
def func2(a: int, *args: str): | ||
v1 = (a, *args) | ||
t1: Literal["tuple[int | str, ...]"] = reveal_type(v1) | ||
|
||
|
||
def func3(a: int, b: str, *args: str): | ||
v1 = (*args, a, *args, b, *(a, b, a)) | ||
t1: Literal["tuple[str | int, ...]"] = reveal_type(v1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters