-
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 recent regression that resulted in a false positive error when …
…using bidirectional type inference for an assignment to a class-scoped variable where the annotated type is a descriptor. This addresses #5455.
- Loading branch information
1 parent
7fcdc92
commit c8ea027
Showing
3 changed files
with
35 additions
and
1 deletion.
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
25 changes: 25 additions & 0 deletions
25
packages/pyright-internal/src/tests/samples/descriptor3.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,25 @@ | ||
# This sample tests that bidirectional type inference works when | ||
# assigning to a class-scoped variable that is annotated with a | ||
# descriptor. The setter type should not be used in this case. | ||
|
||
|
||
from typing import Callable, Generic, TypeVar | ||
|
||
|
||
T = TypeVar("T") | ||
|
||
|
||
class Desc1(Generic[T]): | ||
def __get__(self, instance: object | None, owner: type | None = None) -> list[T]: | ||
... | ||
|
||
def __set__(self, instance: object, value: list[T]) -> None: | ||
... | ||
|
||
|
||
def func1(factory: Callable[[], list[T]]) -> Desc1[T]: | ||
... | ||
|
||
|
||
class ClassA: | ||
not_working: Desc1[int] = func1(list) |
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