forked from microsoft/pyright
-
Notifications
You must be signed in to change notification settings - Fork 0
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 led to incorrect type evaluation when passing a gene…
…ric class (with a constructor that includes class-scoped TypeVars) as an argument for a callable parameter. The class was being specialized prematurely (with type arguments set to `Unknown`) before the constraint solver was able to solve the higher-order function's type variables. This addresses microsoft#5324. (microsoft#5328) Co-authored-by: Eric Traut <[email protected]>
- Loading branch information
1 parent
47cd514
commit 9bf8231
Showing
3 changed files
with
20 additions
and
2 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
12 changes: 12 additions & 0 deletions
12
packages/pyright-internal/src/tests/samples/genericTypes118.py
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,12 @@ | ||
# This sample tests the case where a generic class is passed as an | ||
# argument to a function that accepts a generic callable parameter. | ||
# The class-scoped TypeVars for the class must be preserved when | ||
# solving the higher-order TypeVars. | ||
|
||
from itertools import compress | ||
from typing import Any, Iterable | ||
|
||
|
||
def func1(a: Iterable[Iterable[tuple[str, int]]], b: Any) -> None: | ||
c = map(compress, a, b) | ||
reveal_type(c, expected_text="map[compress[tuple[str, int]]]") |
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