Skip to content

Commit a46cc51

Browse files
author
theodoreando
committed
fix check-assert-type-fail.test, check-callable.test, check-functools.test, check-inference.test, check-python311.test, check-statements.test, check-varargs.test
1 parent 39f2f19 commit a46cc51

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

test-data/unit/check-assert-type-fail.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def f(si: arr.array[int]):
3030
[case testAssertTypeFailCallableArgKind]
3131
from typing import assert_type, Callable
3232
def myfunc(arg: int) -> None: pass
33-
assert_type(myfunc, Callable[[int], None]) # E: Expression is of type "Callable[[Arg(int, 'arg')], None]", not "Callable[[int], None]"
33+
assert_type(myfunc, Callable[[int], None]) # E: Expression is of type "def myfunc(arg: int) -> None", not "Callable[[int], None]"
3434

3535
[case testAssertTypeOverload]
3636
from typing import assert_type, overload

test-data/unit/check-callable.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -654,13 +654,13 @@ class Call(Protocol):
654654

655655
def f1() -> None: ...
656656
a1: Call = f1 # E: Incompatible types in assignment (expression has type "Callable[[], None]", variable has type "Call") \
657-
# N: "Call.__call__" has type "Callable[[Arg(int, 'x'), VarArg(Any), KwArg(Any)], None]"
657+
# N: "Call.__call__" has type "def __call__(self, x: int, *args: Any, **kwargs: Any) -> None"
658658
def f2(x: str) -> None: ...
659659
a2: Call = f2 # E: Incompatible types in assignment (expression has type "Callable[[str], None]", variable has type "Call") \
660-
# N: "Call.__call__" has type "Callable[[Arg(int, 'x'), VarArg(Any), KwArg(Any)], None]"
660+
# N: "Call.__call__" has type "def __call__(self, x: int, *args: Any, **kwargs: Any) -> None"
661661
def f3(y: int) -> None: ...
662662
a3: Call = f3 # E: Incompatible types in assignment (expression has type "Callable[[int], None]", variable has type "Call") \
663-
# N: "Call.__call__" has type "Callable[[Arg(int, 'x'), VarArg(Any), KwArg(Any)], None]"
663+
# N: "Call.__call__" has type "def __call__(self, x: int, *args: Any, **kwargs: Any) -> None"
664664
def f4(x: int) -> None: ...
665665
a4: Call = f4
666666

test-data/unit/check-functools.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,10 +698,10 @@ use_func_callable(partial(func_b, b=""))
698698
use_int_callable(partial(func_c, b=""))
699699
use_func_callable(partial(func_c, b=""))
700700
use_int_callable(partial(func_fn, b="")) # E: Argument 1 to "use_int_callable" has incompatible type "partial[def (*Any, **Any) -> Any]"; expected "Callable[[int], int]" \
701-
# N: "partial[Callable[[VarArg(Any), KwArg(Any)], Any]].__call__" has type "def __call__(__self, *args: Any, **kwargs: Any) -> def (*Any, **Any) -> Any"
701+
# N: "partial[def (*Any, **Any) -> Any].__call__" has type "def __call__(__self, *args: Any, **kwargs: Any) -> def (*Any, **Any) -> Any"
702702
use_func_callable(partial(func_fn, b=""))
703703
use_int_callable(partial(func_fn_unpack, b="")) # E: Argument 1 to "use_int_callable" has incompatible type "partial[def (*Any) -> Any]"; expected "Callable[[int], int]" \
704-
# N: "partial[Callable[[VarArg(Any)], Any]].__call__" has type "def __call__(__self, *args: Any, **kwargs: Any) -> def (*Any) -> Any"
704+
# N: "partial[def (*Any) -> Any].__call__" has type "def __call__(__self, *args: Any, **kwargs: Any) -> def (*Any) -> Any"
705705
use_func_callable(partial(func_fn_unpack, b=""))
706706

707707
# But we should not erase typevars that aren't bound by function

test-data/unit/check-inference.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ def f(*, x: int) -> int: ...
11091109
def g(*, y: int) -> int: ...
11101110
def h(*, x: int) -> int: ...
11111111

1112-
list_1 = [f, g] # E: List item 0 has incompatible type "Callable[[NamedArg(int, 'x')], int]"; expected "Callable[[NamedArg(int, 'y')], int]"
1112+
list_1 = [f, g] # E: List item 0 has incompatible type "def f(*, x: int) -> int"; expected "def g(*, y: int) -> int"
11131113
list_2 = [f, h]
11141114
[builtins fixtures/list.pyi]
11151115

@@ -1434,7 +1434,7 @@ from typing import Callable
14341434
def f(a: Callable[..., None] = lambda *a, **k: None):
14351435
pass
14361436

1437-
def g(a: Callable[..., None] = lambda *a, **k: 1): # E: Incompatible default for argument "a" (default has type "Callable[[VarArg(Any), KwArg(Any)], int]", argument has type "Callable[..., None]")
1437+
def g(a: Callable[..., None] = lambda *a, **k: 1): # E: Incompatible default for argument "a" (default has type "def (*a: Any, **k: Any) -> int", argument has type "Callable[..., None]")
14381438
pass
14391439
[builtins fixtures/dict.pyi]
14401440

@@ -3704,7 +3704,7 @@ def f(x: Call[T]) -> Tuple[T, T]: ...
37043704
def g(__x: str) -> None: pass
37053705
reveal_type(f(g)) # N: Revealed type is "tuple[Never, Never]" \
37063706
# E: Argument 1 to "f" has incompatible type "Callable[[str], None]"; expected "Call[Never]" \
3707-
# N: "Call[Never].__call__" has type "Callable[[NamedArg(Never, 'x')], None]"
3707+
# N: "Call[Never].__call__" has type "def __call__(self, *, x: Never) -> None"
37083708
[builtins fixtures/list.pyi]
37093709

37103710
[case testCallableInferenceAgainstCallableNamedVsPosOnly]
@@ -3720,7 +3720,7 @@ def f(x: Call[T]) -> Tuple[T, T]: ...
37203720

37213721
def g(*, x: str) -> None: pass
37223722
reveal_type(f(g)) # N: Revealed type is "tuple[Never, Never]" \
3723-
# E: Argument 1 to "f" has incompatible type "Callable[[NamedArg(str, 'x')], None]"; expected "Call[Never]" \
3723+
# E: Argument 1 to "f" has incompatible type "def g(*, x: str) -> None"; expected "Call[Never]" \
37243724
# N: "Call[Never].__call__" has type "Callable[[Never], None]"
37253725
[builtins fixtures/list.pyi]
37263726

@@ -3737,7 +3737,7 @@ def f(x: Call[T]) -> Tuple[T, T]: ...
37373737

37383738
def g(**x: str) -> None: pass
37393739
reveal_type(f(g)) # N: Revealed type is "tuple[Never, Never]" \
3740-
# E: Argument 1 to "f" has incompatible type "Callable[[KwArg(str)], None]"; expected "Call[Never]" \
3740+
# E: Argument 1 to "f" has incompatible type "def g(**x: str) -> None"; expected "Call[Never]" \
37413741
# N: "Call[Never].__call__" has type "Callable[[Never], None]"
37423742
[builtins fixtures/list.pyi]
37433743

@@ -3754,8 +3754,8 @@ def f(x: Call[T]) -> Tuple[T, T]: ...
37543754

37553755
def g(*args: str) -> None: pass
37563756
reveal_type(f(g)) # N: Revealed type is "tuple[Never, Never]" \
3757-
# E: Argument 1 to "f" has incompatible type "Callable[[VarArg(str)], None]"; expected "Call[Never]" \
3758-
# N: "Call[Never].__call__" has type "Callable[[NamedArg(Never, 'x')], None]"
3757+
# E: Argument 1 to "f" has incompatible type "def g(*args: str) -> None"; expected "Call[Never]" \
3758+
# N: "Call[Never].__call__" has type "def __call__(self, *, x: Never) -> None"
37593759
[builtins fixtures/list.pyi]
37603760

37613761
[case testInferenceAgainstTypeVarActualBound]

test-data/unit/check-python311.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Alias1 = Callable[[*Ts], int] # E: Variable "__main__.Ts" is not valid as a typ
157157
x1: Alias1[int] # E: Bad number of arguments for type alias, expected 0, given 1
158158
reveal_type(x1) # N: Revealed type is "def (*Any) -> builtins.int"
159159
x1 = good
160-
x1 = bad # E: Incompatible types in assignment (expression has type "Callable[[VarArg(int), NamedArg(int, 'y')], int]", variable has type "Callable[[VarArg(Any)], int]")
160+
x1 = bad # E: Incompatible types in assignment (expression has type "def bad(*x: int, y: int) -> int", variable has type "def (*Any) -> int")
161161

162162
Alias2 = Callable[[*T], int] # E: "T" cannot be unpacked (must be tuple or TypeVarTuple)
163163
x2: Alias2[int]

test-data/unit/check-statements.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2358,6 +2358,6 @@ describe(CAny())
23582358
describe(C())
23592359
describe(CNone())
23602360
describe(CWrong()) # E: Argument 1 to "describe" has incompatible type "CWrong"; expected "Callable[[], None]" \
2361-
# N: "CWrong.__call__" has type "Callable[[Arg(int, 'x')], None]"
2361+
# N: "CWrong.__call__" has type "def __call__(self, x: int) -> None"
23622362
describe(f)
23632363
[builtins fixtures/isinstancelist.pyi]

test-data/unit/check-varargs.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ x: Callable[[int], None]
660660
def f(*x: int) -> None: pass
661661
def g(*x: str) -> None: pass
662662
x = f
663-
x = g # E: Incompatible types in assignment (expression has type "Callable[[VarArg(str)], None]", variable has type "Callable[[int], None]")
663+
x = g # E: Incompatible types in assignment (expression has type "def g(*x: str) -> None", variable has type "Callable[[int], None]")
664664
[builtins fixtures/list.pyi]
665665
[out]
666666

0 commit comments

Comments
 (0)