Skip to content

Commit 4dfccc6

Browse files
stage unit test changes
1 parent 0fa975d commit 4dfccc6

File tree

8 files changed

+31
-31
lines changed

8 files changed

+31
-31
lines changed

test-data/unit/check-functools.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ p = functools.partial(foo, kwarg="asdf")
332332
def bar(a: int, b: str, c: float) -> None: ...
333333
p(bar, 1, "a", 3.0) # OK
334334
p(bar, 1, "a", 3.0, kwarg="asdf") # OK
335-
p(bar, 1, "a", "b") # E: Argument 1 to "foo" has incompatible type "Callable[[int, str, float], None]"; expected "Callable[[int, str, str], None]"
335+
p(bar, 1, "a", "b") # E: Argument 1 to "foo" has incompatible type "(int, str, float) -> None"; expected "(int, str, str) -> None"
336336
[builtins fixtures/dict.pyi]
337337

338338
[case testFunctoolsPartialUnion]
@@ -353,7 +353,7 @@ reveal_type(functools.partial(fn2, 2)()) # N: Revealed type is "Union[builtins.
353353
fn3: Union[Callable[[int], int], str]
354354
reveal_type(functools.partial(fn3, 2)()) # E: "str" not callable \
355355
# N: Revealed type is "builtins.int" \
356-
# E: Argument 1 to "partial" has incompatible type "Union[Callable[[int], int], str]"; expected "Callable[..., int]"
356+
# E: Argument 1 to "partial" has incompatible type "Union[Callable[[int], int], str]"; expected "(..., int)"
357357
[builtins fixtures/tuple.pyi]
358358

359359
[case testFunctoolsPartialUnionOfTypeAndCallable]
@@ -385,8 +385,8 @@ p: partial[str] = partial(generic, resulting_type=str)
385385
q: partial[bool] = partial(generic, resulting_type=str) # E: Argument "resulting_type" to "generic" has incompatible type "Type[str]"; expected "Type[bool]"
386386

387387
pc: Callable[..., str] = partial(generic, resulting_type=str)
388-
qc: Callable[..., bool] = partial(generic, resulting_type=str) # E: Incompatible types in assignment (expression has type "partial[str]", variable has type "Callable[..., bool]") \
389-
# N: "partial[str].__call__" has type "Callable[[VarArg(Any), KwArg(Any)], str]"
388+
qc: Callable[..., bool] = partial(generic, resulting_type=str) # E: Incompatible types in assignment (expression has type "partial[str]", variable has type "(..., bool)") \
389+
# N: "partial[str].__call__" has type "(Any, Any) -> str"
390390
[builtins fixtures/tuple.pyi]
391391

392392
[case testFunctoolsPartialNestedPartial]

test-data/unit/check-inference.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ main:6: error: Need more than 3 values to unpack (4 expected)
400400
[case testInvalidRvalueTypeInInferredMultipleLvarDefinition]
401401
import typing
402402
def f() -> None:
403-
a, b = f # E: "Callable[[], None]" object is not iterable
403+
a, b = f # E: "() -> None" object is not iterable
404404
c, d = A() # E: "A" object is not iterable
405405
class A: pass
406406
[builtins fixtures/for.pyi]
@@ -409,7 +409,7 @@ class A: pass
409409
[case testInvalidRvalueTypeInInferredNestedTupleAssignment]
410410
import typing
411411
def f() -> None:
412-
a1, (a2, b) = A(), f # E: "Callable[[], None]" object is not iterable
412+
a1, (a2, b) = A(), f # E: "() -> None" object is not iterable
413413
a3, (c, d) = A(), A() # E: "A" object is not iterable
414414
class A: pass
415415
[builtins fixtures/for.pyi]
@@ -988,7 +988,7 @@ a = k2
988988
if int():
989989
a = k2
990990
if int():
991-
a = k1 # E: Incompatible types in assignment (expression has type "Callable[[int, List[T@k1]], List[Union[T@k1, int]]]", variable has type "Callable[[S, List[T@k2]], List[Union[T@k2, int]]]")
991+
a = k1 # E: Incompatible types in assignment (expression has type "(int, List[T@k1]) -> List[Union[T@k1, int]]", variable has type "(S, List[T@k2]) -> List[Union[T@k2, int]]")
992992
b = k1
993993
if int():
994994
b = k1
@@ -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 "(x: int) -> int"; expected "(y: int) -> int"
11131113
list_2 = [f, h]
11141114
[builtins fixtures/list.pyi]
11151115

@@ -1390,14 +1390,14 @@ from typing import List, Callable
13901390
li = [1]
13911391
l = lambda: li
13921392
f1 = l # type: Callable[[], List[int]]
1393-
f2 = l # type: Callable[[], List[str]] # E: Incompatible types in assignment (expression has type "Callable[[], List[int]]", variable has type "Callable[[], List[str]]")
1393+
f2 = l # type: Callable[[], List[str]] # E: Incompatible types in assignment (expression has type "() -> List[int]", variable has type "() -> List[str]")
13941394
[builtins fixtures/list.pyi]
13951395

13961396
[case testInferLambdaType2]
13971397
from typing import List, Callable
13981398
l = lambda: [B()]
13991399
f1 = l # type: Callable[[], List[B]]
1400-
f2 = l # type: Callable[[], List[A]] # E: Incompatible types in assignment (expression has type "Callable[[], List[B]]", variable has type "Callable[[], List[A]]")
1400+
f2 = l # type: Callable[[], List[A]] # E: Incompatible types in assignment (expression has type "() -> List[B]", variable has type "() -> List[A]")
14011401

14021402
class A: pass
14031403
class B: pass
@@ -1435,7 +1435,7 @@ from typing import Callable
14351435
def f(a: Callable[..., None] = lambda *a, **k: None):
14361436
pass
14371437

1438-
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]")
1438+
def g(a: Callable[..., None] = lambda *a, **k: 1): # E: Incompatible default for argument "a" (default has type "(Any, Any) -> int", argument has type "(..., None)")
14391439
pass
14401440
[builtins fixtures/dict.pyi]
14411441

test-data/unit/check-namedtuple.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ b = B._make(['']) # type: B
549549
[case testNamedTupleIncompatibleRedefinition]
550550
from typing import NamedTuple
551551
class Crash(NamedTuple):
552-
count: int # E: Incompatible types in assignment (expression has type "int", base class "tuple" defined the type as "Callable[[Tuple[int, ...], object], int]")
552+
count: int # E: Incompatible types in assignment (expression has type "int", base class "tuple" defined the type as "(Tuple[int, ...], object) -> int")
553553
[builtins fixtures/tuple.pyi]
554554

555555
[case testNamedTupleInClassNamespace]

test-data/unit/check-recursive-types.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,5 +1012,5 @@ p = ta
10121012
from typing import Callable
10131013
from bogus import Foo # type: ignore
10141014

1015-
A = Callable[[Foo, "B"], Foo] # E: Type alias target becomes "Callable[[Any, B], Any]" due to an unfollowed import
1016-
B = Callable[[Foo, A], Foo] # E: Type alias target becomes "Callable[[Any, A], Any]" due to an unfollowed import
1015+
A = Callable[[Foo, "B"], Foo] # E: Type alias target becomes "(Any, B) -> Any" due to an unfollowed import
1016+
B = Callable[[Foo, A], Foo] # E: Type alias target becomes "(Any, A) -> Any" due to an unfollowed import

test-data/unit/daemon.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ $ dmypy inspect foo.py:3:10:3:17 -vv
456456
$ dmypy inspect foo.py:9:9:9:11
457457
"int"
458458
$ dmypy inspect foo.py:11:1:11:3
459-
"Callable[[Optional[int]], None]"
459+
"(Optional[int]) -> None"
460460
$ dmypy inspect foo.py:11:1:13:1
461461
"None"
462462
$ dmypy inspect foo.py:1:2:3:4
@@ -517,7 +517,7 @@ $ dmypy inspect foo.py:7:5 -vv
517517
$ dmypy inspect foo.py:7:5 -vv --limit=1
518518
"builtins.int"
519519
$ dmypy inspect foo.py:7:3
520-
"Callable[[int], None]"
520+
"(int) -> None"
521521
"None"
522522
$ dmypy inspect foo.py:1:2
523523
Can't find any expressions at position 1:2

test-data/unit/fine-grained.test

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ class A:
13401340
[out]
13411341
==
13421342
-- This is a bad error message
1343-
main:7: error: Argument 1 to "use" has incompatible type "Type[A]"; expected "Callable[[], A]"
1343+
main:7: error: Argument 1 to "use" has incompatible type "Type[A]"; expected "() -> A"
13441344

13451345
[case testConstructorSignatureChanged3]
13461346
from a import C
@@ -2227,7 +2227,7 @@ class B:
22272227
x: int
22282228
[out]
22292229
==
2230-
a.py:3: error: Argument 1 to "deca" has incompatible type "Callable[[B], B]"; expected "Callable[[str], str]"
2230+
a.py:3: error: Argument 1 to "deca" has incompatible type "(B) -> B"; expected "(str) -> str"
22312231
==
22322232
a.py:6: error: "B" has no attribute "x"
22332233
==
@@ -2295,7 +2295,7 @@ class B:
22952295
x: int
22962296
[out]
22972297
==
2298-
a.py:4: error: Argument 1 to "deca" has incompatible type "Callable[[B], B]"; expected "Callable[[str], str]"
2298+
a.py:4: error: Argument 1 to "deca" has incompatible type "(B) -> B"; expected "(str) -> str"
22992299
==
23002300
a.py:7: error: "B" has no attribute "x"
23012301
==
@@ -2363,7 +2363,7 @@ class B:
23632363
x: int
23642364
[out]
23652365
==
2366-
a.py:4: error: Argument 1 to "deca" has incompatible type "Callable[[D, B], B]"; expected "Callable[..., str]"
2366+
a.py:4: error: Argument 1 to "deca" has incompatible type "(D, B) -> B"; expected "(..., str)"
23672367
==
23682368
a.py:7: error: "B" has no attribute "x"
23692369
==
@@ -2389,7 +2389,7 @@ def dec(func: Callable[[str], str]) -> Callable[[str], str]:
23892389
pass
23902390
[out]
23912391
==
2392-
a.py:5: error: Argument 1 to "dec" has incompatible type "Callable[[int], int]"; expected "Callable[[str], str]"
2392+
a.py:5: error: Argument 1 to "dec" has incompatible type "(int) -> int"; expected "(str) -> str"
23932393

23942394
[case testDecoratorUpdateNestedClass]
23952395
import a
@@ -2414,7 +2414,7 @@ class C:
24142414
pass
24152415
[out]
24162416
==
2417-
a.py:6: error: Argument 1 to "dec" of "C" has incompatible type "Callable[[Inner, int], int]"; expected "Callable[..., str]"
2417+
a.py:6: error: Argument 1 to "dec" of "C" has incompatible type "(Inner, int) -> int"; expected "(..., str)"
24182418

24192419
[case testDecoratorUpdateClassInFunction]
24202420
import a
@@ -2450,7 +2450,7 @@ class B:
24502450
x: str
24512451
[out]
24522452
==
2453-
a.py:6: error: Argument 1 to "dec" of "C" has incompatible type "Callable[[Inner, B], int]"; expected "Callable[..., str]"
2453+
a.py:6: error: Argument 1 to "dec" of "C" has incompatible type "(Inner, B) -> int"; expected "(..., str)"
24542454
==
24552455
a.py:8: error: Incompatible return value type (got "str", expected "int")
24562456

@@ -2480,7 +2480,7 @@ def dec(f: Callable[[C], int]) -> Callable[[int], int]:
24802480
pass
24812481
[out]
24822482
==
2483-
a.py:3: error: Argument 1 to "dec" has incompatible type "Callable[[B], int]"; expected "Callable[[C], int]"
2483+
a.py:3: error: Argument 1 to "dec" has incompatible type "(B) -> int"; expected "(C) -> int"
24842484

24852485
[case testOverloadRefresh]
24862486
from typing import overload
@@ -4514,9 +4514,9 @@ x = 0
45144514
x = ''
45154515
[builtins fixtures/tuple.pyi]
45164516
[out]
4517-
b.py:5: error: Incompatible types in assignment (expression has type "int", base class "tuple" defined the type as "Callable[[Tuple[int, ...], object], int]")
4517+
b.py:5: error: Incompatible types in assignment (expression has type "int", base class "tuple" defined the type as "(Tuple[int, ...], object) -> int")
45184518
==
4519-
b.py:5: error: Incompatible types in assignment (expression has type "int", base class "tuple" defined the type as "Callable[[Tuple[int, ...], object], int]")
4519+
b.py:5: error: Incompatible types in assignment (expression has type "int", base class "tuple" defined the type as "(Tuple[int, ...], object) -> int")
45204520

45214521
[case testReprocessEllipses1]
45224522
import a
@@ -6161,7 +6161,7 @@ class C:
61616161
pass
61626162
[out]
61636163
==
6164-
a.py:6: error: Argument 1 to "func" has incompatible type "Type[C]"; expected "Callable[[int], Any]"
6164+
a.py:6: error: Argument 1 to "func" has incompatible type "Type[C]"; expected "(int) -> Any"
61656165

61666166
[case testDunderNewDefine]
61676167
import a
@@ -8094,7 +8094,7 @@ def A(x: str) -> str: pass
80948094
[builtins fixtures/list.pyi]
80958095
[out]
80968096
==
8097-
a.py:4: error: Incompatible import of "A" (imported name has type "Callable[[str], str]", local name has type "Type[List[Any]]")
8097+
a.py:4: error: Incompatible import of "A" (imported name has type "(str) -> str", local name has type "Type[List[Any]]")
80988098

80998099
[case testFakeOverloadCrash]
81008100
import b

test-data/unit/pythoneval-asyncio.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ try:
364364
finally:
365365
loop.close()
366366
[out]
367-
_program.py:17: error: Argument 1 to "add_done_callback" of "Future" has incompatible type "Callable[[Future[int]], None]"; expected "Callable[[Future[str]], object]"
367+
_program.py:17: error: Argument 1 to "add_done_callback" of "Future" has incompatible type "(Future[int]) -> None"; expected "(Future[str]) -> object"
368368

369369
[case testErrorOneMoreFutureInReturnType]
370370
import typing

test-data/unit/pythoneval.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ def f(*args: str) -> str: return args[0]
616616
map(f, ['x'])
617617
map(f, [1])
618618
[out]
619-
_program.py:4: error: Argument 1 to "map" has incompatible type "Callable[[VarArg(str)], str]"; expected "Callable[[int], str]"
619+
_program.py:4: error: Argument 1 to "map" has incompatible type "(str) -> str"; expected "(int) -> str"
620620

621621
[case testMapStr]
622622
import typing
@@ -823,7 +823,7 @@ class MyDDict(t.DefaultDict[int,T], t.Generic[T]):
823823
MyDDict(dict)['0']
824824
MyDDict(dict)[0]
825825
[out]
826-
_program.py:7: error: Argument 1 to "defaultdict" has incompatible type "Type[List[Any]]"; expected "Optional[Callable[[], str]]"
826+
_program.py:7: error: Argument 1 to "defaultdict" has incompatible type "Type[List[Any]]"; expected "Optional[() -> str]"
827827
_program.py:10: error: Invalid index type "str" for "defaultdict[int, str]"; expected type "int"
828828
_program.py:10: error: Incompatible types in assignment (expression has type "int", target has type "str")
829829
_program.py:20: error: Argument 1 to "tst" has incompatible type "defaultdict[str, List[Never]]"; expected "defaultdict[int, List[Never]]"

0 commit comments

Comments
 (0)