mirror of
https://github.com/microsoft/pyright.git
synced 2024-09-11 07:55:56 +03:00
Fixed regression that results in incorrect type evaluation for annotations that involve nested protocols (such as P[P[T]]
). This addresses #6767. (#7963)
This commit is contained in:
parent
7fb7b4158d
commit
51225759d2
@ -537,7 +537,7 @@ export function assignTypeToTypeVar(
|
||||
adjWideTypeBound,
|
||||
newNarrowTypeBound,
|
||||
diag?.createAddendum(),
|
||||
typeVarContext,
|
||||
/* destTypeVarContext */ undefined,
|
||||
/* srcTypeVarContext */ undefined,
|
||||
AssignTypeFlags.IgnoreTypeVarScope,
|
||||
recursionCount
|
||||
|
18
packages/pyright-internal/src/tests/samples/protocol50.py
Normal file
18
packages/pyright-internal/src/tests/samples/protocol50.py
Normal file
@ -0,0 +1,18 @@
|
||||
# This sample tests the case where a protocol is used as a type argument
|
||||
# for itself.
|
||||
|
||||
from typing import Generic, Protocol, TypeVar
|
||||
|
||||
V_co = TypeVar("V_co", covariant=True)
|
||||
|
||||
|
||||
class Proto1(Generic[V_co]):
|
||||
def f(self, /) -> V_co: ...
|
||||
|
||||
|
||||
class Proto2(Protocol[V_co]):
|
||||
def f(self, /) -> V_co: ...
|
||||
|
||||
|
||||
def func1(v0: Proto1[Proto1[object]]):
|
||||
v2: Proto2[Proto2[object]] = v0
|
@ -575,6 +575,12 @@ test('Protocol49', () => {
|
||||
TestUtils.validateResults(analysisResults, 0);
|
||||
});
|
||||
|
||||
test('Protocol50', () => {
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['protocol50.py']);
|
||||
|
||||
TestUtils.validateResults(analysisResults, 0);
|
||||
});
|
||||
|
||||
test('ProtocolExplicit1', () => {
|
||||
const analysisResults = TestUtils.typeAnalyzeSampleFiles(['protocolExplicit1.py']);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user