-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed bug that resulted in false positive error when calling the same generic function with a ParamSpec multiple times as separate arguments within a call expression. This addresses #5453. * Fixed another ParamSpec-related issue. This addresses #5454. --------- Co-authored-by: Eric Traut <[email protected]>
- Loading branch information
1 parent
6bae226
commit e1063f1
Showing
3 changed files
with
87 additions
and
34 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
32 changes: 32 additions & 0 deletions
32
packages/pyright-internal/src/tests/samples/paramSpec45.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,32 @@ | ||
# This sample tests the case where the same function that uses a ParamSpec | ||
# is called multiple times as arguments to the same call. | ||
|
||
from typing import Callable, ParamSpec | ||
|
||
P = ParamSpec("P") | ||
|
||
|
||
def func1(func: Callable[P, object], *args: P.args, **kwargs: P.kwargs) -> object: | ||
... | ||
|
||
|
||
def func2(x: str) -> int: | ||
... | ||
|
||
|
||
def func3(y: str) -> int: | ||
... | ||
|
||
|
||
print(func1(func2, x="..."), func1(func3, y="...")) | ||
|
||
|
||
def func4(fn: Callable[P, int], *args: P.args, **kwargs: P.kwargs) -> int: | ||
return fn(*args, **kwargs) | ||
|
||
|
||
def func5(x: int, y: int) -> int: | ||
return x + y | ||
|
||
|
||
func5(func4(lambda x: x, 1), func4(lambda x, y: x + y, 2, 3)) |
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