-
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 results in a false positive error under certain circum…
…stances involving a call to a higher-order generic function with another function that involves a class with a contravariant type variable. This addresses #7212.
- Loading branch information
Showing
3 changed files
with
38 additions
and
3 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
26 changes: 26 additions & 0 deletions
26
packages/pyright-internal/src/tests/samples/solverHigherOrder12.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,26 @@ | ||
# This sample tests the case involving a higher-order function and a | ||
# class that uses a contravariant type variable. | ||
|
||
from collections.abc import Callable | ||
from typing import TypeVar, Generic | ||
|
||
T = TypeVar("T", contravariant=True) | ||
A = TypeVar("A") | ||
B = TypeVar("B") | ||
C = TypeVar("C") | ||
|
||
|
||
class ClassA(Generic[T]): | ||
pass | ||
|
||
|
||
def func1(c: Callable[[A], None], v: A): | ||
pass | ||
|
||
|
||
def func2(c: ClassA[B]) -> None: | ||
pass | ||
|
||
|
||
def func3(c: ClassA[int]): | ||
func1(func2, c) |
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