-
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 results in incorrect type evaluation when performing p…
…rotocol matching that involves an attribute with a callable type parameterized by a ParamSpec. This addresses #9330. (#9344)
- Loading branch information
Showing
3 changed files
with
31 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
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,24 @@ | ||
# This sample tests the case where a protocol includes a callable | ||
# attribute that is an instance variable. It shouldn't be bound | ||
# to the concrete class in this case. | ||
|
||
from typing import Callable, Protocol | ||
|
||
|
||
class A: | ||
def __init__(self, *, p1: int, p2: str) -> None: ... | ||
|
||
|
||
class ProtoB[**P, T](Protocol): | ||
x: Callable[P, T] | ||
|
||
|
||
class B: | ||
x: type[A] | ||
|
||
|
||
def func1[**P, T](v: ProtoB[P, T]) -> Callable[P, T]: ... | ||
|
||
|
||
x1 = func1(B()) | ||
reveal_type(x1, expected_text="(*, p1: int, p2: str) -> A") |
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