-
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 bug that led to false negative when evaluating a call to a func…
- Loading branch information
Showing
3 changed files
with
111 additions
and
4 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
59 changes: 59 additions & 0 deletions
59
packages/pyright-internal/src/tests/samples/paramSpec49.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,59 @@ | ||
# This sample tests the case where a function parameterized with a | ||
# ParamSpec P is called with *args: P.args and **kwargs: P.kwargs. | ||
|
||
from typing import Any, Generic, ParamSpec | ||
|
||
P = ParamSpec("P") | ||
|
||
|
||
class TaskDeclaration(Generic[P]): | ||
pass | ||
|
||
|
||
class Dispatcher: | ||
def dispatch( | ||
self, | ||
task_declaration: TaskDeclaration[P], | ||
count: int, | ||
/, | ||
*args: P.args, | ||
**kwargs: P.kwargs, | ||
) -> None: | ||
pass | ||
|
||
|
||
class Queue: | ||
dispatcher: Dispatcher | ||
|
||
def method1(self, stub: TaskDeclaration[P]) -> Any: | ||
def inner0(*args: P.args, **kwargs: P.kwargs) -> None: | ||
self.dispatcher.dispatch(stub, 1, *args, **kwargs) | ||
|
||
def inner1(*args: P.args, **kwargs: P.kwargs) -> None: | ||
self.dispatcher.dispatch(stub, 1, **kwargs, *args) | ||
|
||
def inner2(*args: P.args, **kwargs: P.kwargs) -> None: | ||
# This should generate an error because it's missing | ||
# a positional argument for 'count'. | ||
self.dispatcher.dispatch(stub, *args, **kwargs) | ||
|
||
def inner3(*args: P.args, **kwargs: P.kwargs) -> None: | ||
# This should generate an error because it has an | ||
# additional positional argument. | ||
self.dispatcher.dispatch(stub, 1, 1, *args, **kwargs) | ||
|
||
def inner4(*args: P.args, **kwargs: P.kwargs) -> None: | ||
# This should generate an error because it is missing | ||
# the *args argument. | ||
self.dispatcher.dispatch(stub, 1, **kwargs) | ||
|
||
def inner5(*args: P.args, **kwargs: P.kwargs) -> None: | ||
# This should generate an error because it is missing | ||
# the *kwargs argument. | ||
self.dispatcher.dispatch(stub, 1, *args) | ||
|
||
def inner6(*args: P.args, **kwargs: P.kwargs) -> None: | ||
# This should generate an error because it has an | ||
# extra *args argument. | ||
self.dispatcher.dispatch(stub, 1, *args, *args, **kwargs) | ||
|
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