Skip to content

Consistent quote wrapping around MessageBuilder.format #3873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Aug 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b4b7de9
Consistent quote wrapping around MessageBuilder.format as per issue #…
May 23, 2017
466a832
No quotes around Module
May 23, 2017
dc7c243
And even more tests that need to be updated
May 23, 2017
df58633
incorrect indentation
May 24, 2017
ba55b1a
Consistent quote wrapping around MessageBuilder.format as per issue #…
May 23, 2017
e134f8f
No quotes around Module
May 23, 2017
60231de
And even more tests that need to be updated
May 23, 2017
735778e
incorrect indentation
May 24, 2017
5922be3
update tests & merge conflicts
May 30, 2017
b349b8e
and even more merge conflicts
May 30, 2017
6a45cad
Merge trunk into quotewrap
Aug 24, 2017
048dae1
Fix trivial quoting mismatches
Aug 24, 2017
3bba4bd
Remove message-specific quoting from protocol error messages
Aug 24, 2017
e6e1701
Quote Callable types in message output
Aug 25, 2017
d884e03
Update MessageBuilder.note_call to remove double-quoting of types
Aug 25, 2017
e0b5a30
Fix non-pytest test failures
Aug 25, 2017
04393b6
Merge remote-tracking branch 'upstream/master' into quotewrap
Aug 25, 2017
fc11a6f
Move FunctionLike formatting from MessageBuilder.format to _format_si…
Aug 27, 2017
f288a60
Move fallback formatting from MessageBuilder.format to _format_simple
Aug 27, 2017
e10a803
Remove MessageBuilder.format_simple
Aug 27, 2017
b4f0b78
Introduce MessageBuilder.format_bare
Aug 27, 2017
4bb8d3f
Use MessageBuilder.format_bare where appropriate
Aug 27, 2017
8a27e2c
Move * and ** inside quotes in MessageBuilder.incompatible_argument
Aug 27, 2017
6a7ec9b
Merge remote-tracking branch 'upstream/master' into quotewrap
Aug 27, 2017
a8fe400
Fix long line
Aug 27, 2017
daa6792
Fix up now-inaccurate comments
Aug 29, 2017
96961c0
Elaborate on the bare parameter in format_distinctly
Aug 30, 2017
5bc7251
Don't quote <nothing> or <deleted> in messages
Aug 30, 2017
a84b4bb
Don't surround tuple(length N) in quotes in message output
Aug 30, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 106 additions & 101 deletions mypy/messages.py

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions test-data/unit/check-abstract.test
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def f(cls: Type[A]) -> A:
def g() -> A:
return A() # E: Cannot instantiate abstract class 'A' with abstract attribute 'm'

f(A) # E: Only concrete class can be given where 'Type[A]' is expected
f(B) # E: Only concrete class can be given where 'Type[A]' is expected
f(A) # E: Only concrete class can be given where "Type[A]" is expected
f(B) # E: Only concrete class can be given where "Type[A]" is expected
f(C) # OK
x: Type[B]
f(x) # OK
Expand All @@ -200,7 +200,7 @@ Alias = A
GoodAlias = C
Alias() # E: Cannot instantiate abstract class 'A' with abstract attribute 'm'
GoodAlias()
f(Alias) # E: Only concrete class can be given where 'Type[A]' is expected
f(Alias) # E: Only concrete class can be given where "Type[A]" is expected
f(GoodAlias)
[out]

Expand All @@ -218,14 +218,14 @@ class C(B):

var: Type[A]
var()
var = A # E: Can only assign concrete classes to a variable of type 'Type[A]'
var = B # E: Can only assign concrete classes to a variable of type 'Type[A]'
var = A # E: Can only assign concrete classes to a variable of type "Type[A]"
var = B # E: Can only assign concrete classes to a variable of type "Type[A]"
var = C # OK

var_old = None # type: Type[A] # Old syntax for variable annotations
var_old()
var_old = A # E: Can only assign concrete classes to a variable of type 'Type[A]'
var_old = B # E: Can only assign concrete classes to a variable of type 'Type[A]'
var_old = A # E: Can only assign concrete classes to a variable of type "Type[A]"
var_old = B # E: Can only assign concrete classes to a variable of type "Type[A]"
var_old = C # OK
[out]

Expand Down
40 changes: 20 additions & 20 deletions test-data/unit/check-async-await.test
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand All @@ -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]

Expand All @@ -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]

Expand Down Expand Up @@ -164,7 +164,7 @@ async def f() -> None:
[typing fixtures/typing-full.pyi]
[out]
main:4: error: AsyncIterable expected
main:4: error: List[int] has no attribute "__aiter__"
main:4: error: "List[int]" has no attribute "__aiter__"

[case testAsyncForTypeComments]

Expand Down Expand Up @@ -248,13 +248,13 @@ async def wrong_iterable(obj: Iterable[int]):

[out]
main:18: error: AsyncIterable expected
main:18: error: Iterable[int] has no attribute "__aiter__"; maybe "__iter__"?
main:18: error: "Iterable[int]" has no attribute "__aiter__"; maybe "__iter__"?
main:19: error: Iterable expected
main:19: error: asyncify[int] has no attribute "__iter__"; maybe "__aiter__"?
main:19: error: "asyncify[int]" has no attribute "__iter__"; maybe "__aiter__"?
main:20: error: AsyncIterable expected
main:20: error: Iterable[int] has no attribute "__aiter__"; maybe "__iter__"?
main:20: error: "Iterable[int]" has no attribute "__aiter__"; maybe "__iter__"?
main:21: error: Iterable expected
main:21: error: asyncify[int] has no attribute "__iter__"; maybe "__aiter__"?
main:21: error: "asyncify[int]" has no attribute "__iter__"; maybe "__aiter__"?
[builtins fixtures/async_await.pyi]
[typing fixtures/typing-full.pyi]

Expand Down Expand Up @@ -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]
Expand All @@ -301,7 +301,7 @@ class C:
def __aenter__(self) -> None: pass
async def __aexit__(self, x, y, z) -> None: pass
async def f() -> None:
async with C() as x: # E: None has no attribute "__await__"
async with C() as x: # E: "None" has no attribute "__await__"
pass
[builtins fixtures/async_await.pyi]
[typing fixtures/typing-full.pyi]
Expand All @@ -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]")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is still some inconsistency in formatting attribute names here __aexit__ and few lines above "__await__". Would you like to fix this in a separate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I suspect these will be more about specific message cleanup than anything else; I'll file an issue with the list of things you've spotted, so I don't lose track of them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened #3887 for this.

pass
[builtins fixtures/async_await.pyi]
[typing fixtures/typing-full.pyi]
Expand All @@ -323,7 +323,7 @@ class C:
async def __aenter__(self) -> int: pass
def __aexit__(self, x, y, z) -> None: pass
async def f() -> None:
async with C() as x: # E: None has no attribute "__await__"
async with C() as x: # E: "None" has no attribute "__await__"
pass
[builtins fixtures/async_await.pyi]
[typing fixtures/typing-full.pyi]
Expand Down Expand Up @@ -383,7 +383,7 @@ def g() -> Generator[Any, None, str]:
[builtins fixtures/async_await.pyi]
[typing fixtures/typing-full.pyi]
[out]
main:6: error: "yield from" can't be applied to Awaitable[str]
main:6: error: "yield from" can't be applied to "Awaitable[str]"

[case testAwaitableSubclass]

Expand Down Expand Up @@ -550,7 +550,7 @@ def h() -> None:

[out]
main:9: error: Iterable expected
main:9: error: AsyncGenerator[int, None] has no attribute "__iter__"; maybe "__aiter__"?
main:9: error: "AsyncGenerator[int, None]" has no attribute "__iter__"; maybe "__aiter__"?

[case testAsyncGeneratorNoYieldFrom]
# flags: --fast-parser --python-version 3.6
Expand Down Expand Up @@ -636,19 +636,19 @@ def plain_host_generator() -> Generator[str, None, None]:
yield 'a'
x = 0
x = yield from plain_generator()
x = yield from plain_coroutine() # E: "yield from" can't be applied to Awaitable[int]
x = yield from plain_coroutine() # E: "yield from" can't be applied to "Awaitable[int]"
x = yield from decorated_generator()
x = yield from decorated_coroutine() # E: "yield from" can't be applied to AwaitableGenerator[Any, Any, int, Awaitable[int]]
x = yield from decorated_coroutine() # E: "yield from" can't be applied to "AwaitableGenerator[Any, Any, int, Awaitable[int]]"
x = yield from other_iterator()
x = yield from other_coroutine() # E: "yield from" can't be applied to "Aw"

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]")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar situation here: await vs "yield from" few lines above.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But again, this is a story for a separate PR.

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
Expand All @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions test-data/unit/check-class-namedtuple.test
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class MyNamedTuple(NamedTuple):
a: int
b: str

MyNamedTuple.x # E: Type[MyNamedTuple] has no attribute "x"
MyNamedTuple.x # E: "Type[MyNamedTuple]" has no attribute "x"

[case testNewNamedTupleEmptyItems]
# flags: --python-version 3.6
Expand Down Expand Up @@ -439,13 +439,13 @@ class HasNone(NamedTuple):
y: Optional[int] = None

reveal_type(HasNone(1)) # E: Revealed type is 'Tuple[builtins.int, Union[builtins.int, builtins.None], fallback=__main__.HasNone]'
HasNone(None) # E: Argument 1 to "HasNone" has incompatible type None; expected "int"
HasNone(None) # E: Argument 1 to "HasNone" has incompatible type "None"; expected "int"
HasNone(1, y=None)
HasNone(1, y=2)

class CannotBeNone(NamedTuple):
x: int
y: int = None # E: Incompatible types in assignment (expression has type None, variable has type "int")
y: int = None # E: Incompatible types in assignment (expression has type "None", variable has type "int")

[builtins fixtures/list.pyi]

Expand Down
Loading