Repository: python/mypy

Issue:
Inconsistent attribute quoting in some error messages
@ilevkivskyi has pointed out some inconsistent attribute quoting in their review of #3873. We've agreed to handle those in a separate PR, so I'm putting a list here so I don't lose track of them:

* `__aexit__` should be quoted in `Incompatible types in "async with" for __aexit__ (actual type "int", expected type "Awaitable[Any]")` 
(https://github.com/python/mypy/pull/3873/files/daa6792ae1ddaf85ce94dd8e674b27d119183509#r135941496)
* `await` should be quoted in `Incompatible types in await` (for consistency with `"yield from" can't be applied to ...`) (https://github.com/python/mypy/pull/3873/files/daa6792ae1ddaf85ce94dd8e674b27d119183509#r135941626)
* The first quoted part of `'Add5.__call__' has type "Callable[[Arg(int, 'x')], int]"` should use double-quotes (https://github.com/python/mypy/pull/3873/files/daa6792ae1ddaf85ce94dd8e674b27d119183509#r135942783)



Discussion:
@ilevkivskyi Can you confirm that I've captured your comments accurately?

(I apparently can't assign this to myself, but I will take care of it after #3873 has landed.)
Yes, everything is right.

Resolving patch:
diff --git a/mypy/messages.py b/mypy/messages.py
--- a/mypy/messages.py
+++ b/mypy/messages.py
@@ -45,12 +45,12 @@
 INCOMPATIBLE_TYPES = 'Incompatible types'
 INCOMPATIBLE_TYPES_IN_ASSIGNMENT = 'Incompatible types in assignment'
 INCOMPATIBLE_REDEFINITION = 'Incompatible redefinition'
-INCOMPATIBLE_TYPES_IN_AWAIT = 'Incompatible types in await'
-INCOMPATIBLE_TYPES_IN_ASYNC_WITH_AENTER = 'Incompatible types in "async with" for __aenter__'
-INCOMPATIBLE_TYPES_IN_ASYNC_WITH_AEXIT = 'Incompatible types in "async with" for __aexit__'
+INCOMPATIBLE_TYPES_IN_AWAIT = 'Incompatible types in "await"'
+INCOMPATIBLE_TYPES_IN_ASYNC_WITH_AENTER = 'Incompatible types in "async with" for "__aenter__"'
+INCOMPATIBLE_TYPES_IN_ASYNC_WITH_AEXIT = 'Incompatible types in "async with" for "__aexit__"'
 INCOMPATIBLE_TYPES_IN_ASYNC_FOR = 'Incompatible types in "async for"'
 
-INCOMPATIBLE_TYPES_IN_YIELD = 'Incompatible types in yield'
+INCOMPATIBLE_TYPES_IN_YIELD = 'Incompatible types in "yield"'
 INCOMPATIBLE_TYPES_IN_YIELD_FROM = 'Incompatible types in "yield from"'
 INCOMPATIBLE_TYPES_IN_STR_INTERPOLATION = 'Incompatible types in string interpolation'
 MUST_HAVE_NONE_RETURN_TYPE = 'The return type of "{}" must be None'
@@ -1027,7 +1027,7 @@ def concrete_only_call(self, typ: Type, context: Context) -> None:
                   .format(self.format(typ)), context)
 
     def note_call(self, subtype: Type, call: Type, context: Context) -> None:
-        self.note("'{}.__call__' has type {}".format(self.format_bare(subtype),
+        self.note('"{}.__call__" has type {}'.format(self.format_bare(subtype),
                                                      self.format(call, verbosity=1)), context)
 
     def report_protocol_problems(self, subtype: Union[Instance, TupleType, TypedDictType],


Test patch:
diff --git a/test-data/unit/check-async-await.test b/test-data/unit/check-async-await.test
--- a/test-data/unit/check-async-await.test
+++ b/test-data/unit/check-async-await.test
@@ -93,7 +93,7 @@ async def f() -> int:
     return x
 [typing fixtures/typing-full.pyi]
 [out]
-main:7: error: Incompatible types in await (actual type "Generator[int, None, str]", expected type "Awaitable[Any]")
+main:7: error: Incompatible types in "await" (actual type "Generator[int, None, str]", expected type "Awaitable[Any]")
 
 [case testAwaitIteratorError]
 
@@ -105,7 +105,7 @@ async def f() -> int:
     return x
 [typing fixtures/typing-full.pyi]
 [out]
-main:6: error: Incompatible types in await (actual type "Iterator[Any]", expected type "Awaitable[Any]")
+main:6: error: Incompatible types in "await" (actual type "Iterator[Any]", expected type "Awaitable[Any]")
 
 [case testAwaitArgumentError]
 
@@ -117,7 +117,7 @@ async def f() -> int:
 [builtins fixtures/async_await.pyi]
 [typing fixtures/typing-full.pyi]
 [out]
-main:5: error: Incompatible types in await (actual type "int", expected type "Awaitable[Any]")
+main:5: error: Incompatible types in "await" (actual type "int", expected type "Awaitable[Any]")
 
 [case testAwaitResultError]
 
@@ -290,7 +290,7 @@ class C:
     def __aenter__(self) -> int: pass
     async def __aexit__(self, x, y, z) -> None: pass
 async def f() -> None:
-    async with C() as x:  # E: Incompatible types in "async with" for __aenter__ (actual type "int", expected type "Awaitable[Any]")
+    async with C() as x:  # E: Incompatible types in "async with" for "__aenter__" (actual type "int", expected type "Awaitable[Any]")
         pass
 [builtins fixtures/async_await.pyi]
 [typing fixtures/typing-full.pyi]
@@ -312,7 +312,7 @@ class C:
     async def __aenter__(self) -> int: pass
     def __aexit__(self, x, y, z) -> int: pass
 async def f() -> None:
-    async with C() as x: # E: Incompatible types in "async with" for __aexit__ (actual type "int", expected type "Awaitable[Any]")
+    async with C() as x: # E: Incompatible types in "async with" for "__aexit__" (actual type "int", expected type "Awaitable[Any]")
         pass
 [builtins fixtures/async_await.pyi]
 [typing fixtures/typing-full.pyi]
@@ -419,7 +419,7 @@ from types import coroutine
 @coroutine
 def f() -> Generator[int, str, int]:
     x = yield 0
-    x = yield ''  # E: Incompatible types in yield (actual type "str", expected type "int")
+    x = yield ''  # E: Incompatible types in "yield" (actual type "str", expected type "int")
     reveal_type(x)  # E: Revealed type is 'builtins.str'
     if x:
         return 0
@@ -443,7 +443,7 @@ async def g() -> AsyncGenerator[int, None]:
     reveal_type(value)  # E: Revealed type is 'builtins.int*'
     yield value
 
-    yield 'not an int'  # E: Incompatible types in yield (actual type "str", expected type "int")
+    yield 'not an int'  # E: Incompatible types in "yield" (actual type "str", expected type "int")
     # return without a value is fine
     return
 reveal_type(g)  # E: Revealed type is 'def () -> typing.AsyncGenerator[builtins.int, builtins.None]'
@@ -466,7 +466,7 @@ from typing import AsyncIterator
 async def gen() -> AsyncIterator[int]:
     yield 3
 
-    yield 'not an int'  # E: Incompatible types in yield (actual type "str", expected type "int")
+    yield 'not an int'  # E: Incompatible types in "yield" (actual type "str", expected type "int")
 
 async def use_gen() -> None:
     async for item in gen():
@@ -644,11 +644,11 @@ def plain_host_generator() -> Generator[str, None, None]:
 
 async def plain_host_coroutine() -> None:
     x = 0
-    x = await plain_generator()  # E: Incompatible types in await (actual type "Generator[str, None, int]", expected type "Awaitable[Any]")
+    x = await plain_generator()  # E: Incompatible types in "await" (actual type "Generator[str, None, int]", expected type "Awaitable[Any]")
     x = await plain_coroutine()
     x = await decorated_generator()
     x = await decorated_coroutine()
-    x = await other_iterator()  # E: Incompatible types in await (actual type "It", expected type "Awaitable[Any]")
+    x = await other_iterator()  # E: Incompatible types in "await" (actual type "It", expected type "Awaitable[Any]")
     x = await other_coroutine()
 
 @coroutine
@@ -665,11 +665,11 @@ def decorated_host_generator() -> Generator[str, None, None]:
 @coroutine
 async def decorated_host_coroutine() -> None:
     x = 0
-    x = await plain_generator()  # E: Incompatible types in await (actual type "Generator[str, None, int]", expected type "Awaitable[Any]")
+    x = await plain_generator()  # E: Incompatible types in "await" (actual type "Generator[str, None, int]", expected type "Awaitable[Any]")
     x = await plain_coroutine()
     x = await decorated_generator()
     x = await decorated_coroutine()
-    x = await other_iterator()  # E: Incompatible types in await (actual type "It", expected type "Awaitable[Any]")
+    x = await other_iterator()  # E: Incompatible types in "await" (actual type "It", expected type "Awaitable[Any]")
     x = await other_coroutine()
 
 [builtins fixtures/async_await.pyi]
diff --git a/test-data/unit/check-expressions.test b/test-data/unit/check-expressions.test
--- a/test-data/unit/check-expressions.test
+++ b/test-data/unit/check-expressions.test
@@ -1215,7 +1215,7 @@ from typing import Iterator, Callable
 lambda: (yield)
 
 gen: Callable[[], Iterator[str]]
-gen = (lambda: (yield 1))  # E: Incompatible types in yield (actual type "int", expected type "str")
+gen = (lambda: (yield 1))  # E: Incompatible types in "yield" (actual type "int", expected type "str")
 
 def fun(cb: Callable[[], Iterator[str]]) -> None:
     pass
diff --git a/test-data/unit/check-protocols.test b/test-data/unit/check-protocols.test
--- a/test-data/unit/check-protocols.test
+++ b/test-data/unit/check-protocols.test
@@ -1664,7 +1664,7 @@ reveal_type(apply_gen(Add5())) # E: Revealed type is 'builtins.int*'
 def apply_str(f: Callable[[str], int], x: str) -> int:
     return f(x)
 apply_str(Add5(), 'a') # E: Argument 1 to "apply_str" has incompatible type "Add5"; expected "Callable[[str], int]" \
-                       # N: 'Add5.__call__' has type "Callable[[Arg(int, 'x')], int]"
+                       # N: "Add5.__call__" has type "Callable[[Arg(int, 'x')], int]"
 [builtins fixtures/isinstancelist.pyi]
 
 [case testMoreComplexCallableStructuralSubtyping]
@@ -1681,9 +1681,9 @@ class Bad2:
     def __call__(self, y: int, *rest: str) -> int: pass
 call_soon(Good())
 call_soon(Bad1()) # E: Argument 1 to "call_soon" has incompatible type "Bad1"; expected "Callable[[int, VarArg(str)], int]" \
-                  # N: 'Bad1.__call__' has type "Callable[[Arg(int, 'x'), VarArg(int)], int]"
+                  # N: "Bad1.__call__" has type "Callable[[Arg(int, 'x'), VarArg(int)], int]"
 call_soon(Bad2()) # E: Argument 1 to "call_soon" has incompatible type "Bad2"; expected "Callable[[int, VarArg(str)], int]" \
-                  # N: 'Bad2.__call__' has type "Callable[[Arg(int, 'y'), VarArg(str)], int]"
+                  # N: "Bad2.__call__" has type "Callable[[Arg(int, 'y'), VarArg(str)], int]"
 [builtins fixtures/isinstancelist.pyi]
 
 [case testStructuralSupportForPartial]
diff --git a/test-data/unit/check-statements.test b/test-data/unit/check-statements.test
--- a/test-data/unit/check-statements.test
+++ b/test-data/unit/check-statements.test
@@ -1050,7 +1050,7 @@ while x == 5: ...  # E: Trying to read deleted variable 'x'
 from typing import Iterator
 def f() -> Iterator[int]:
     yield 1
-    yield '' # E: Incompatible types in yield (actual type "str", expected type "int")
+    yield '' # E: Incompatible types in "yield" (actual type "str", expected type "int")
 [builtins fixtures/for.pyi]
 [out]