Skip to content

Commit 823667d

Browse files
authored
Fix crash during ParamSpec inference (#14118)
Fixes #13903 The fix is straightforward, the formal to actual map needs to be refreshed twice, after both using external _and_ internal type context.
1 parent 885e361 commit 823667d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

test-data/unit/check-parameter-specification.test

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,3 +1281,18 @@ class Some(Generic[P]):
12811281
# TODO: this probably should be reported.
12821282
def call(*args: P.args, **kwargs: P.kwargs): ...
12831283
[builtins fixtures/paramspec.pyi]
1284+
1285+
[case testParamSpecInferenceCrash]
1286+
from typing import Callable, Generic, ParamSpec, TypeVar
1287+
1288+
def foo(x: int) -> int: ...
1289+
T = TypeVar("T")
1290+
def bar(x: T) -> T: ...
1291+
1292+
P = ParamSpec("P")
1293+
1294+
class C(Generic[P]):
1295+
def __init__(self, fn: Callable[P, int], *args: P.args, **kwargs: P.kwargs): ...
1296+
1297+
reveal_type(bar(C(fn=foo, x=1))) # N: Revealed type is "__main__.C[[x: builtins.int]]"
1298+
[builtins fixtures/paramspec.pyi]

0 commit comments

Comments
 (0)