-
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 bug that produces a false negative when attempting to assign a …
…method to a `Callable` type where the first parameter of the method is typed as `Self`, but the callback requires the class itself. This addresses #6568. (#6569)
- Loading branch information
Showing
4 changed files
with
13 additions
and
27 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
10 changes: 6 additions & 4 deletions
10
packages/pyright-internal/src/tests/samples/memberAccess11.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
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,18 +1,17 @@ | ||
# This sample tests the case where a method decorator uses an explicit | ||
# type annotation for the "self" parameter. | ||
|
||
from typing import Callable, Generic, TypeVar | ||
from typing import Callable, Generic, TypeVar, Any | ||
|
||
_T = TypeVar("_T") | ||
T = TypeVar("T") | ||
S = TypeVar("S", bound="MyClass[Any]") | ||
|
||
|
||
def my_generic_wrapper( | ||
f: Callable[["MyClass[_T]"], str] | ||
) -> Callable[["MyClass[_T]"], int]: | ||
def my_generic_wrapper(f: Callable[[S], str]) -> Callable[[S], int]: | ||
... | ||
|
||
|
||
class MyClass(Generic[_T]): | ||
class MyClass(Generic[T]): | ||
@my_generic_wrapper | ||
def do_something(self) -> str: | ||
... |