Skip to content

Commit

Permalink
Fix crash during ParamSpec inference (#14118)
Browse files Browse the repository at this point in the history
Fixes #13903 

The fix is straightforward, the formal to actual map needs to be
refreshed twice, after both using external _and_ internal type context.
  • Loading branch information
ilevkivskyi authored Nov 17, 2022
1 parent 885e361 commit 823667d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test-data/unit/check-parameter-specification.test
Original file line number Diff line number Diff line change
Expand Up @@ -1281,3 +1281,18 @@ class Some(Generic[P]):
# TODO: this probably should be reported.
def call(*args: P.args, **kwargs: P.kwargs): ...
[builtins fixtures/paramspec.pyi]

[case testParamSpecInferenceCrash]
from typing import Callable, Generic, ParamSpec, TypeVar

def foo(x: int) -> int: ...
T = TypeVar("T")
def bar(x: T) -> T: ...

P = ParamSpec("P")

class C(Generic[P]):
def __init__(self, fn: Callable[P, int], *args: P.args, **kwargs: P.kwargs): ...

reveal_type(bar(C(fn=foo, x=1))) # N: Revealed type is "__main__.C[[x: builtins.int]]"
[builtins fixtures/paramspec.pyi]

0 comments on commit 823667d

Please sign in to comment.