Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on ParamSpec in incremental mode #14885

Merged
merged 2 commits into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mypy/fixup.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def visit_class_def(self, c: ClassDef) -> None:
if isinstance(v, TypeVarType):
for value in v.values:
value.accept(self.type_fixer)
v.upper_bound.accept(self.type_fixer)
v.upper_bound.accept(self.type_fixer)

def visit_type_var_expr(self, tv: TypeVarExpr) -> None:
for value in tv.values:
Expand Down
26 changes: 26 additions & 0 deletions test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -6403,3 +6403,29 @@ def g(d: Dict[TValue]) -> TValue:
tmp/b.py:6: error: TypedDict "a.Dict[TValue]" has no key "x"
[out2]
tmp/b.py:6: error: TypedDict "a.Dict[TValue]" has no key "y"

[case testParamSpecNoCrash]
import m
[file m.py]
from typing import Callable, TypeVar
from lib import C

T = TypeVar("T")
def test(x: Callable[..., T]) -> T: ...
test(C) # type: ignore

[file m.py.2]
from typing import Callable, TypeVar
from lib import C

T = TypeVar("T")
def test(x: Callable[..., T]) -> T: ...
test(C) # type: ignore
# touch
[file lib.py]
from typing import ParamSpec, Generic, Callable

P = ParamSpec("P")
class C(Generic[P]):
def __init__(self, fn: Callable[P, int]) -> None: ...
[builtins fixtures/dict.pyi]