Skip to content

Commit 4365dad

Browse files
authored
Fix crash on ParamSpec in incremental mode (#14885)
Fixes #14687 Fixes #14353
1 parent 70d4bb2 commit 4365dad

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

mypy/fixup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def visit_class_def(self, c: ClassDef) -> None:
170170
if isinstance(v, TypeVarType):
171171
for value in v.values:
172172
value.accept(self.type_fixer)
173-
v.upper_bound.accept(self.type_fixer)
173+
v.upper_bound.accept(self.type_fixer)
174174

175175
def visit_type_var_expr(self, tv: TypeVarExpr) -> None:
176176
for value in tv.values:

test-data/unit/check-incremental.test

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6403,3 +6403,29 @@ def g(d: Dict[TValue]) -> TValue:
64036403
tmp/b.py:6: error: TypedDict "a.Dict[TValue]" has no key "x"
64046404
[out2]
64056405
tmp/b.py:6: error: TypedDict "a.Dict[TValue]" has no key "y"
6406+
6407+
[case testParamSpecNoCrash]
6408+
import m
6409+
[file m.py]
6410+
from typing import Callable, TypeVar
6411+
from lib import C
6412+
6413+
T = TypeVar("T")
6414+
def test(x: Callable[..., T]) -> T: ...
6415+
test(C) # type: ignore
6416+
6417+
[file m.py.2]
6418+
from typing import Callable, TypeVar
6419+
from lib import C
6420+
6421+
T = TypeVar("T")
6422+
def test(x: Callable[..., T]) -> T: ...
6423+
test(C) # type: ignore
6424+
# touch
6425+
[file lib.py]
6426+
from typing import ParamSpec, Generic, Callable
6427+
6428+
P = ParamSpec("P")
6429+
class C(Generic[P]):
6430+
def __init__(self, fn: Callable[P, int]) -> None: ...
6431+
[builtins fixtures/dict.pyi]

0 commit comments

Comments
 (0)