Skip to content

Commit d94a2a9

Browse files
author
theodoreando
committed
fix check-typevar-tuple
1 parent a46cc51 commit d94a2a9

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

test-data/unit/check-typevar-tuple.test

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -518,15 +518,15 @@ call(target=func, args=(0, 'foo'))
518518
call(target=func, args=('bar', 'foo')) # E: Argument "target" to "call" has incompatible type "Callable[[int, str], None]"; expected "Callable[[str, str], None]"
519519
call(target=func, args=(True, 'foo', 0)) # E: Argument "target" to "call" has incompatible type "Callable[[int, str], None]"; expected "Callable[[bool, str, int], None]"
520520
call(target=func, args=(0, 0, 'foo')) # E: Argument "target" to "call" has incompatible type "Callable[[int, str], None]"; expected "Callable[[int, int, str], None]"
521-
call(target=func, args=vargs) # E: Argument "target" to "call" has incompatible type "Callable[[int, str], None]"; expected "Callable[[VarArg(int)], None]"
521+
call(target=func, args=vargs) # E: Argument "target" to "call" has incompatible type "Callable[[int, str], None]"; expected "def (*int) -> None"
522522

523523
# NOTE: This behavior may be a bit contentious, it is maybe inconsistent with our handling of
524524
# PEP646 but consistent with our handling of callable constraints.
525-
call(target=func2, args=vargs) # E: Argument "target" to "call" has incompatible type "Callable[[int, int], None]"; expected "Callable[[VarArg(int)], None]"
525+
call(target=func2, args=vargs) # E: Argument "target" to "call" has incompatible type "Callable[[int, int], None]"; expected "def (*int) -> None"
526526
call(target=func3, args=vargs)
527527
call(target=func3, args=(0,1))
528-
call(target=func3, args=(0,'foo')) # E: Argument "target" to "call" has incompatible type "Callable[[VarArg(int)], None]"; expected "Callable[[int, str], None]"
529-
call(target=func3, args=vargs_str) # E: Argument "target" to "call" has incompatible type "Callable[[VarArg(int)], None]"; expected "Callable[[VarArg(str)], None]"
528+
call(target=func3, args=(0,'foo')) # E: Argument "target" to "call" has incompatible type "def func3(*args: int) -> None"; expected "Callable[[int, str], None]"
529+
call(target=func3, args=vargs_str) # E: Argument "target" to "call" has incompatible type "def func3(*args: int) -> None"; expected "def (*str) -> None"
530530
[builtins fixtures/tuple.pyi]
531531

532532
[case testTypeVarTuplePep646CallableWithPrefixSuffix]
@@ -1903,7 +1903,7 @@ def foo3(func: Callable[[int, Unpack[Args2]], T], *args: Unpack[Args2]) -> T:
19031903
return submit2(func, 1, *args)
19041904

19051905
def foo_bad(func: Callable[[Unpack[Args2]], T], *args: Unpack[Args2]) -> T:
1906-
return submit2(func, 1, *args) # E: Argument 1 to "submit2" has incompatible type "Callable[[VarArg(Unpack[Args2])], T]"; expected "Callable[[int, VarArg(Unpack[Args2])], T]"
1906+
return submit2(func, 1, *args) # E: Argument 1 to "submit2" has incompatible type "def (*Unpack[Args2]) -> T"; expected "def (int, /, *Unpack[Args2]) -> T"
19071907
[builtins fixtures/tuple.pyi]
19081908

19091909
[case testTypeVarTupleParamSpecInteraction]
@@ -2321,8 +2321,8 @@ higher_order(good2)
23212321
higher_order(ok1)
23222322
higher_order(ok2)
23232323

2324-
higher_order(bad1) # E: Argument 1 to "higher_order" has incompatible type "Callable[[NamedArg(str, 'd')], int]"; expected "Callable[[VarArg(Any)], Any]"
2325-
higher_order(bad2) # E: Argument 1 to "higher_order" has incompatible type "Callable[[KwArg(None)], None]"; expected "Callable[[VarArg(Any)], Any]"
2324+
higher_order(bad1) # E: Argument 1 to "higher_order" has incompatible type "def bad1(*, d: str) -> int"; expected "def (*Any) -> Any"
2325+
higher_order(bad2) # E: Argument 1 to "higher_order" has incompatible type "def bad2(**kwargs: None) -> None"; expected "def (*Any) -> Any"
23262326
[builtins fixtures/tuple.pyi]
23272327

23282328
[case testAliasToCallableWithUnpack2]
@@ -2338,10 +2338,10 @@ def bad3(*, d: str) -> int: ...
23382338
def bad4(**kwargs: None) -> None: ...
23392339

23402340
higher_order(good)
2341-
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]"
2342-
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]"
2343-
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]"
2344-
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]"
2341+
higher_order(bad1) # E: Argument 1 to "higher_order" has incompatible type "Callable[[str, int], None]"; expected "def (int, str, /, *Unpack[tuple[Unpack[tuple[Any, ...]], int]]) -> Any"
2342+
higher_order(bad2) # E: Argument 1 to "higher_order" has incompatible type "def bad2(c: bytes, *args: int) -> str"; expected "def (int, str, /, *Unpack[tuple[Unpack[tuple[Any, ...]], int]]) -> Any"
2343+
higher_order(bad3) # E: Argument 1 to "higher_order" has incompatible type "def bad3(*, d: str) -> int"; expected "def (int, str, /, *Unpack[tuple[Unpack[tuple[Any, ...]], int]]) -> Any"
2344+
higher_order(bad4) # E: Argument 1 to "higher_order" has incompatible type "def bad4(**kwargs: None) -> None"; expected "def (int, str, /, *Unpack[tuple[Unpack[tuple[Any, ...]], int]]) -> Any"
23452345
[builtins fixtures/tuple.pyi]
23462346

23472347
[case testAliasToCallableWithUnpackInvalid]
@@ -2357,7 +2357,7 @@ Alias = Callable[[Unpack[T]], int] # E: "T" cannot be unpacked (must be tuple o
23572357
x: Alias[int]
23582358
reveal_type(x) # N: Revealed type is "def (*Any) -> builtins.int"
23592359
x = good
2360-
x = bad # E: Incompatible types in assignment (expression has type "Callable[[VarArg(int), NamedArg(int, 'y')], int]", variable has type "Callable[[VarArg(Any)], int]")
2360+
x = bad # E: Incompatible types in assignment (expression has type "def bad(*x: int, y: int) -> int", variable has type "def (*Any) -> int")
23612361
[builtins fixtures/tuple.pyi]
23622362

23632363
[case testTypeVarTupleInvariant]
@@ -2443,7 +2443,7 @@ class CM(Generic[R]): ...
24432443
def cm(fn: Callable[P, List[R]]) -> Callable[P, CM[R]]: ...
24442444

24452445
Ts = TypeVarTuple("Ts")
2446-
@cm # E: Argument 1 to "cm" has incompatible type "Callable[[VarArg(Unpack[Ts])], tuple[Unpack[Ts]]]"; expected "Callable[[VarArg(Never)], list[Never]]"
2446+
@cm # E: Argument 1 to "cm" has incompatible type "def [Ts`-1] test(*args: Unpack[Ts]) -> tuple[Unpack[Ts]]"; expected "def (*args: Never) -> list[Never]"
24472447
def test(*args: Unpack[Ts]) -> Tuple[Unpack[Ts]]: ...
24482448

24492449
reveal_type(test) # N: Revealed type is "def (*args: Never) -> __main__.CM[Never]"

0 commit comments

Comments
 (0)