@@ -15,7 +15,7 @@ def foo1(x: Callable[P, int]) -> Callable[P, str]: ...
1515def foo2(x: P) -> P: ... # E: Invalid location for ParamSpec "P" \
1616 # N: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]'
1717
18- # TODO(shantanu ): uncomment once we have support for Concatenate
18+ # TODO(PEP612 ): uncomment once we have support for Concatenate
1919# def foo3(x: Concatenate[int, P]) -> int: ... $ E: Invalid location for Concatenate
2020
2121def foo4(x: List[P]) -> None: ... # E: Invalid location for ParamSpec "P" \
@@ -29,6 +29,7 @@ def foo6(x: Callable[[P], int]) -> None: ... # E: Invalid location for ParamSpe
2929[builtins fixtures/tuple.pyi]
3030
3131[case testParamSpecTemporaryAnyBehaviour]
32+ # TODO(PEP612): behaviour tested here should change
3233# This is a test of mypy's temporary behaviour in lieu of full support for ParamSpec
3334from typing import Callable, List, Iterator, TypeVar
3435from typing_extensions import ParamSpec
@@ -50,3 +51,28 @@ def whatever(x: int) -> Iterator[int]:
5051reveal_type(whatever) # N: Revealed type is "def (*Any, **Any) -> builtins.list[builtins.int*]"
5152reveal_type(whatever(217)) # N: Revealed type is "builtins.list[builtins.int*]"
5253[builtins fixtures/tuple.pyi]
54+
55+ [case testGenericParamSpecTemporaryBehaviour]
56+ # flags: --python-version 3.10
57+ # TODO(PEP612): behaviour tested here should change
58+ from typing import Generic, TypeVar, Callable, ParamSpec
59+
60+ T = TypeVar("T")
61+ P = ParamSpec("P")
62+
63+ class X(Generic[T, P]): # E: Free type variable expected in Generic[...]
64+ f: Callable[P, int] # E: The first argument to Callable must be a list of types or "..."
65+ x: T
66+ [out]
67+
68+ [case testInvalidParamSpecType]
69+ # flags: --python-version 3.10
70+ from typing import ParamSpec
71+
72+ P = ParamSpec("P")
73+
74+ class MyFunction(P): # E: Invalid location for ParamSpec "P" \
75+ # N: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]'
76+ ...
77+
78+ a: MyFunction[int] # E: "MyFunction" expects no type arguments, but 1 given
0 commit comments