Skip to content

Commit 587c30c

Browse files
committed
Simplify the testcase
1 parent c3cfe46 commit 587c30c

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

test-data/unit/check-functools.test

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,11 @@ def func_fn_unpack(fn: Callable[[Unpack[Ts]], Tc], b: str) -> Callable[[Unpack[T
690690
return fn
691691

692692
# We should not leak stray typevars that aren't in scope:
693+
reveal_type(partial(func_b, b="")) # N: Revealed type is "functools.partial[Any]"
694+
reveal_type(partial(func_c, b="")) # N: Revealed type is "functools.partial[Any]"
695+
reveal_type(partial(func_fn, b="")) # N: Revealed type is "functools.partial[def (*Any, **Any) -> Any]"
696+
reveal_type(partial(func_fn_unpack, b="")) # N: Revealed type is "functools.partial[def (*Any) -> Any]"
697+
693698
use_int_callable(partial(func_b, b=""))
694699
use_func_callable(partial(func_b, b=""))
695700
use_int_callable(partial(func_c, b=""))
@@ -709,20 +714,17 @@ def outer_b(arg: Tb) -> None:
709714
def inner(a: Tb, b: str) -> Tb:
710715
return a
711716

712-
def call(fn: Callable[[int], int]) -> int:
713-
return fn(0)
714-
715-
call(partial(inner, b="")) # E: Argument 1 to "call" has incompatible type "partial[Tb]"; expected "Callable[[int], int]" \
716-
# N: "partial[Tb].__call__" has type "Callable[[VarArg(Any), KwArg(Any)], Tb]"
717+
reveal_type(partial(inner, b="")) # N: Revealed type is "functools.partial[Tb`-1]"
718+
use_int_callable(partial(inner, b="")) # E: Argument 1 to "use_int_callable" has incompatible type "partial[Tb]"; expected "Callable[[int], int]" \
719+
# N: "partial[Tb].__call__" has type "Callable[[VarArg(Any), KwArg(Any)], Tb]"
717720

718721
def outer_c(arg: Tc) -> None:
719722

720723
def inner(a: Tc, b: str) -> Tc:
721724
return a
722725

723-
def call(fn: Callable[[int], int]) -> int:
724-
return fn(0)
725-
726-
call(partial(inner, b="")) # E: Argument 1 to "call" has incompatible type "partial[str]"; expected "Callable[[int], int]" \
727-
# N: "partial[str].__call__" has type "Callable[[VarArg(Any), KwArg(Any)], str]"
726+
reveal_type(partial(inner, b="")) # N: Revealed type is "functools.partial[builtins.int]" \
727+
# N: Revealed type is "functools.partial[builtins.str]"
728+
use_int_callable(partial(inner, b="")) # E: Argument 1 to "use_int_callable" has incompatible type "partial[str]"; expected "Callable[[int], int]" \
729+
# N: "partial[str].__call__" has type "Callable[[VarArg(Any), KwArg(Any)], str]"
728730
[builtins fixtures/tuple.pyi]

0 commit comments

Comments
 (0)