@@ -2235,3 +2235,45 @@ z: Tuple[int, Unpack[Tuple[int, ...]]] = (1,)
2235
2235
w: Tuple[int, Unpack[Tuple[int, ...]]] = (1, *[2, 3, 4])
2236
2236
t: Tuple[int, Unpack[Tuple[int, ...]]] = (1, *(2, 3, 4))
2237
2237
[builtins fixtures/tuple.pyi]
2238
+
2239
+ [case testAliasToCallableWithUnpack]
2240
+ from typing import Any, Callable, Tuple, Unpack
2241
+
2242
+ _CallableValue = Callable[[Unpack[Tuple[Any, ...]]], Any]
2243
+ def higher_order(f: _CallableValue) -> None: ...
2244
+
2245
+ def good1(*args: int) -> None: ...
2246
+ def good2(*args: str) -> int: ...
2247
+
2248
+ def bad1(a: str, b: int, /) -> None: ...
2249
+ def bad2(c: bytes, *args: int) -> str: ...
2250
+ def bad3(*, d: str) -> int: ...
2251
+ def bad4(**kwargs: None) -> None: ...
2252
+
2253
+ higher_order(good1)
2254
+ higher_order(good2)
2255
+
2256
+ higher_order(bad1) # E: Argument 1 to "higher_order" has incompatible type "Callable[[str, int], None]"; expected "Callable[[VarArg(Any)], Any]"
2257
+ higher_order(bad2) # E: Argument 1 to "higher_order" has incompatible type "Callable[[bytes, VarArg(int)], str]"; expected "Callable[[VarArg(Any)], Any]"
2258
+ higher_order(bad3) # E: Argument 1 to "higher_order" has incompatible type "Callable[[NamedArg(str, 'd')], int]"; expected "Callable[[VarArg(Any)], Any]"
2259
+ higher_order(bad4) # E: Argument 1 to "higher_order" has incompatible type "Callable[[KwArg(None)], None]"; expected "Callable[[VarArg(Any)], Any]"
2260
+ [builtins fixtures/tuple.pyi]
2261
+
2262
+ [case testAliasToCallableWithUnpack2]
2263
+ from typing import Any, Callable, Tuple, Unpack
2264
+
2265
+ _CallableValue = Callable[[int, str, Unpack[Tuple[Any, ...]], int], Any]
2266
+ def higher_order(f: _CallableValue) -> None: ...
2267
+
2268
+ def good(a: int, b: str, *args: Unpack[Tuple[Unpack[Tuple[Any, ...]], int]]) -> int: ...
2269
+ def bad1(a: str, b: int, /) -> None: ...
2270
+ def bad2(c: bytes, *args: int) -> str: ...
2271
+ def bad3(*, d: str) -> int: ...
2272
+ def bad4(**kwargs: None) -> None: ...
2273
+
2274
+ higher_order(good)
2275
+ higher_order(bad1) # E: Argument 1 to "higher_order" has incompatible type "Callable[[str, int], None]"; expected "Callable[[int, str, VarArg(Unpack[Tuple[Unpack[Tuple[Any, ...]], int]])], Any]"
2276
+ higher_order(bad2) # E: Argument 1 to "higher_order" has incompatible type "Callable[[bytes, VarArg(int)], str]"; expected "Callable[[int, str, VarArg(Unpack[Tuple[Unpack[Tuple[Any, ...]], int]])], Any]"
2277
+ higher_order(bad3) # E: Argument 1 to "higher_order" has incompatible type "Callable[[NamedArg(str, 'd')], int]"; expected "Callable[[int, str, VarArg(Unpack[Tuple[Unpack[Tuple[Any, ...]], int]])], Any]"
2278
+ higher_order(bad4) # E: Argument 1 to "higher_order" has incompatible type "Callable[[KwArg(None)], None]"; expected "Callable[[int, str, VarArg(Unpack[Tuple[Unpack[Tuple[Any, ...]], int]])], Any]"
2279
+ [builtins fixtures/tuple.pyi]
0 commit comments