8000 Update error messages · python/mypy@d83faaf · GitHub
[go: up one dir, main page]

Skip to content

Commit d83faaf

Browse files
committed
Update error messages
1 parent 02961f4 commit d83faaf

8 files changed

+22
-22
lines changed

mypy/messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def format_simple(self, typ: Type, verbosity: int = 0) -> str:
253253
base_str = itype.type.fullname()
254254
else:
255255
base_str = itype.type.name()
256-
if itype.args == [] or len(itype.args) == 1 and type(itype.args[0]) == AnyType:
256+
if itype.args == []:
257257
# No type arguments. Place the type name in quotes to avoid
258258
# potential for confusion: otherwise, the type name could be
259259
# interpreted as a normal word.

test-data/unit/check-async-await.test

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async def f() -> int:
9393
return x
9494
[typing fixtures/typing-full.pyi]
9595
[out]
96-
main:7: error: Incompatible types in await (actual type Generator[int, None, str], expected type "Awaitable")
96+
main:7: error: Incompatible types in await (actual type Generator[int, None, str], expected type Awaitable[Any])
9797

9898
[case testAwaitIteratorError]
9999

@@ -105,7 +105,7 @@ async def f() -> int:
105105
return x
106106
[typing fixtures/typing-full.pyi]
107107
[out]
108-
main:6: error: Incompatible types in await (actual type "Iterator", expected type "Awaitable")
108+
main:6: error: Incompatible types in await (actual type Iterator[Any], expected type Awaitable[Any])
109109

110110
[case testAwaitArgumentError]
111111

@@ -117,7 +117,7 @@ async def f() -> int:
117117
[builtins fixtures/async_await.pyi]
118118
[typing fixtures/typing-full.pyi]
119119
[out]
120-
main:5: error: Incompatible types in await (actual type "int", expected type "Awaitable")
120+
main:5: error: Incompatible types in await (actual type "int", expected type Awaitable[Any])
121121

122122
[case testAwaitResultError]
123123

@@ -290,7 +290,7 @@ class C:
290290
def __aenter__(self) -> int: pass
291291
async def __aexit__(self, x, y, z) -> None: pass
292292
async def f() -> None:
293-
async with C() as x: # E: Incompatible types in "async with" for __aenter__ (actual type "int", expected type "Awaitable")
293+
async with C() as x: # E: Incompatible types in "async with" for __aenter__ (actual type "int", expected type Awaitable[Any])
294294
pass
295295
[builtins fixtures/async_await.pyi]
296296
[typing fixtures/typing-full.pyi]
@@ -312,7 +312,7 @@ class C:
312312
async def __aenter__(self) -> int: pass
313313
def __aexit__(self, x, y, z) -> int: pass
314314
async def f() -> None:
315-
async with C() as x: # E: Incompatible types in "async with" for __aexit__ (actual type "int", expected type "Awaitable")
315+
async with C() as x: # E: Incompatible types in "async with" for __aexit__ (actual type "int", expected type Awaitable[Any])
316316
pass
317317
[builtins fixtures/async_await.pyi]
318318
[typing fixtures/typing-full.pyi]
@@ -644,11 +644,11 @@ def plain_host_generator() -> Generator[str, None, None]:
644644

645645
async def plain_host_coroutine() -> None:
646646
x = 0
647-
x = await plain_generator() # E: Incompatible types in await (actual type Generator[str, None, int], expected type "Awaitable")
647+
x = await plain_generator() # E: Incompatible types in await (actual type Generator[str, None, int], expected type Awaitable[Any])
648648
x = await plain_coroutine()
649649
x = await decorated_generator()
650650
x = await decorated_coroutine()
651-
x = await other_iterator() # E: Incompatible types in await (actual type "It", expected type "Awaitable")
651+
x = await other_iterator() # E: Incompatible types in await (actual type "It", expected type Awaitable[Any])
652652
x = await other_coroutine()
653653

654654
@coroutine
@@ -665,11 +665,11 @@ def decorated_host_generator() -> Generator[str, None, None]:
665665
@coroutine
666666
async def decorated_host_coroutine() -> None:
667667
x = 0
668-
x = await plain_generator() # E: Incompatible types in await (actual type Generator[str, None, int], expected type "Awaitable")
668+
x = await plain_generator() # E: Incompatible types in await (actual type Generator[str, None, int], expected type Awaitable[Any])
669669
x = await plain_coroutine()
670670
x = await decorated_generator()
671671
x = await decorated_coroutine()
672-
x = await other_iterator() # E: Incompatible types in await (actual type "It", expected type "Awaitable")
672+
x = await other_iterator() # E: Incompatible types in await (actual type "It", expected type Awaitable[Any])
673673
x = await other_coroutine()
674674

675675
[builtins fixtures/async_await.pyi]

test-data/unit/check-functions.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ L = Callable[[Arg(name='x', type=int)], int] # ok
14801480
# I have commented out the following test because I don't know how to expect the "defined here" note part of the error.
14811481
# M = Callable[[Arg(gnome='x', type=int)], int] E: Invalid type alias E: Unexpected keyword argument "gnome" for "Arg"
14821482
N = Callable[[Arg(name=None, type=int)], int] # ok
1483-
O = Callable[[List[Arg(int)]], int] # E: Invalid type alias # E: Value of type "int" is not indexable # E: Type expected within [...] # E: The type Type[list] is not generic and not indexable
1483+
O = Callable[[List[Arg(int)]], int] # E: Invalid type alias # E: Value of type "int" is not indexable # E: Type expected within [...] # E: The type Type[List[Any]] is not generic and not indexable
14841484
P = Callable[[mypy_extensions.VarArg(int)], int] # ok
14851485
Q = Callable[[Arg(int, type=int)], int] # E: Invalid type alias # E: Value of type "int" is not indexable # E: "Arg" gets multiple values for keyword argument "type"
14861486
R = Callable[[Arg(int, 'x', name='y')], int] # E: Invalid type alias # E: Value of type "int" is not indexable # E: "Arg" gets multiple values for keyword argument "name"
@@ -1745,7 +1745,7 @@ f(1, thing_in_kwargs=["hey"])
17451745
from typing import Tuple, Any
17461746
def f(x, *args): # type: (...) -> None
17471747
success_tuple_type = args # type: Tuple[Any, ...]
1748-
fail_tuple_type = args # type: None # E: Incompatible types in assignment (expression has type "tuple", variable has type None)
1748+
fail_tuple_type = args # type: None # E: Incompatible types in assignment (expression has type tuple, variable has type None)
17491749
f(1, "hello")
17501750
[builtins fixtures/tuple.pyi]
17511751
[out]

test-data/unit/check-generic-subtyping.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ a = None # type: A
305305
c = None # type: C
306306
bc = None # type: B[C]
307307

308-
a.x = c # E: Incompatible types in assignment (expression has type "C", variable has type "B")
309-
a.f(c) # E: Argument 1 to "f" of "B" has incompatible type "C"; expected "B"
308+
a.x = c # E: Incompatible types in assignment (expression has type "C", variable has type B[Any])
309+
a.f(c) # E: Argument 1 to "f" of "B" has incompatible type "C"; expected B[Any]
310310
a.x = bc
311311
a.f(bc)
312312
[out]
@@ -325,8 +325,8 @@ class B(Generic[T]):
325325

326326
class A(B):
327327
def g(self) -> None:
328-
self.x = c # E: Incompatible types in assignment (expression has type "C", variable has type "B")
329-
self.f(c) # E: Argument 1 to "f" of "B" has incompatible type "C"; expected "B"
328+
self.x = c # E: Incompatible types in assignment (expression has type "C", variable has type B[Any])
329+
self.f(c) # E: Argument 1 to "f" of "B" has incompatible type "C"; expected B[Any]
330330
self.x = bc
331331
self.f(bc)
332332

test-data/unit/check-generics.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ T = TypeVar('T')
15041504
class C(Generic[T]):
15051505
def __init__(self) -> None: pass
15061506
x = C # type: Callable[[], C[int]]
1507-
y = C # type: Callable[[], int] # E: Incompatible types in assignment (expression has type Type[C], variable has type Callable[[], int])
1507+
y = C # type: Callable[[], int] # E: Incompatible types in assignment (expression has type Type[C[Any]], variable has type Callable[[], int])
15081508

15091509

15101510
-- Special cases

test-data/unit/check-namedtuple.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,12 @@ from typing import NamedTuple
286286

287287
X = NamedTuple('X', [('x', int), ('y', str)])
288288
reveal_type(X._make([5, 'a'])) # E: Revealed type is 'Tuple[builtins.int, builtins.str, fallback=__main__.X]'
289-
X._make('a b') # E: Argument 1 to X._make has incompatible type "str"; expected "Iterable"
289+
X._make('a b') # E: Argument 1 to X._make has incompatible type "str"; expected Iterable[Any]
290290

291291
-- # FIX: not a proper class method
292292
-- x = None # type: X
293293
-- reveal_type(x._make([5, 'a'])) # E: Revealed type is 'Tuple[builtins.int, builtins.str, fallback=__main__.X]'
294-
-- x._make('a b') # E: Argument 1 to X._make has incompatible type "str"; expected "Iterable"
294+
-- x._make('a b') # E: Argument 1 to X._make has incompatible type "str"; expected Iterable[Any]
295295

296296
[builtins fixtures/list.pyi]
297297

test-data/unit/check-tuples.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ from typing import Tuple
9191
t1 = None # type: Tuple[A, A]
9292
t2 = None # type: tuple
9393

94-
t1 = t2 # E: Incompatible types in assignment (expression has type "tuple", variable has type "Tuple[A, A]")
94+
t1 = t2 # E: Incompatible types in assignment (expression has type tuple, variable has type "Tuple[A, A]")
9595
t2 = t1
9696

9797
class A: pass
@@ -914,7 +914,7 @@ def f(a: Tuple) -> None: pass
914914
f(())
915915
f((1,))
916916
f(('', ''))
917-
f(0) # E: Argument 1 to "f" has incompatible type "int"; expected "tuple"
917+
f(0) # E: Argument 1 to "f" has incompatible type "int"; expected tuple
918918
[builtins fixtures/tuple.pyi]
919919

920920
[case testTupleSingleton]

test-data/unit/check-type-checks.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def f(x: object) -> None:
107107
if isinstance(x, C):
108108
x.f(1)
109109
x.f('')
110-
x.g() # E: "C" has no attribute "g"
110+
x.g() # E: C[Any] has no attribute "g"
111111
x.g() # E: "object" has no attribute "g"
112112
[builtins fixtures/isinstance.pyi]
113113
[out]

0 commit comments

Comments
 (0)
0