@@ -15,7 +15,7 @@ def foo1(x: Callable[P, int]) -> Callable[P, str]: ...
15
15
def foo2(x: P) -> P: ... # E: Invalid location for ParamSpec "P" \
16
16
# N: You can use ParamSpec as the first argument to Callable, e.g., 'Callable[P, int]'
17
17
18
- # TODO(shantanu ): uncomment once we have support for Concatenate
18
+ # TODO(PEP612 ): uncomment once we have support for Concatenate
19
19
# def foo3(x: Concatenate[int, P]) -> int: ... $ E: Invalid location for Concatenate
20
20
21
21
def 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
29
29
[builtins fixtures/tuple.pyi]
30
30
31
31
[case testParamSpecTemporaryAnyBehaviour]
32
+ # TODO(PEP612): behaviour tested here should change
32
33
# This is a test of mypy's temporary behaviour in lieu of full support for ParamSpec
33
34
from typing import Callable, List, Iterator, TypeVar
34
35
from typing_extensions import ParamSpec
@@ -50,3 +51,28 @@ def whatever(x: int) -> Iterator[int]:
50
51
reveal_type(whatever) # N: Revealed type is "def (*Any, **Any) -> builtins.list[builtins.int*]"
51
52
reveal_type(whatever(217)) # N: Revealed type is "builtins.list[builtins.int*]"
52
53
[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