-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed a bug that resulted in incorrect type evaluation when calling a…
… `tuple` constructor with bidirectional type inference and the value passed to the constructor is an `Iterable[Any]`. This addresses #7085.
- Loading branch information
Showing
4 changed files
with
41 additions
and
6 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
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 |
---|---|---|
@@ -1,10 +1,17 @@ | ||
# This sample tests the case where the tuple constructor is called | ||
# explicitly with bidirectional type inference. | ||
|
||
from typing import Any, Iterable | ||
|
||
# This should generate an error. | ||
v1: tuple[float] = tuple([1.0, 2.0]) | ||
|
||
# This should generate an error. | ||
v2: tuple[float] | tuple[float, float] = tuple([1.0, 2.0]) | ||
|
||
v3: tuple[float, ...] = tuple([1, 2]) | ||
|
||
|
||
def f(x: Iterable[Any], y: Iterable): | ||
a: tuple[int, int] = tuple(x) | ||
b: tuple[int, int] = tuple(y) |