-
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.
Fixed a bug that results in incorrect type evaluation when passing a …
…function with a callable parameter that uses Concatenate plus ParamSpec to a function that accepts a callable with just a ParamSpec. This addresses #9742.
- Loading branch information
Showing
3 changed files
with
75 additions
and
28 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
24 changes: 24 additions & 0 deletions
24
packages/pyright-internal/src/tests/samples/paramSpec55.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,24 @@ | ||
# This sample tests the case where a function with a ParamSpec | ||
# is assigned to another function with a Concatenate and a ParamSpec. | ||
|
||
from typing import Any, Concatenate, Callable | ||
|
||
|
||
class MyGeneric[**P0]: | ||
def __call__(self, *args: P0.args, **kwargs: P0.kwargs) -> Any: ... | ||
|
||
|
||
def deco1[**P1](func: Callable[[Callable[P1, Any]], Any]) -> MyGeneric[P1]: ... | ||
|
||
|
||
@deco1 | ||
def func1[**P2](func: Callable[Concatenate[int, P2], Any]): ... | ||
|
||
|
||
reveal_type(func1, expected_text="MyGeneric[(int, **P2@func1)]") | ||
|
||
|
||
v1: MyGeneric[[int]] = func1 | ||
|
||
# This should generate an error. | ||
v2: MyGeneric[[int, int]] = func1 |
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