Skip to content

Commit

Permalink
Use double quotes in 'object is not iterable' error message (#10231)
Browse files Browse the repository at this point in the history
  • Loading branch information
dixith authored Mar 21, 2021
1 parent dc08ab6 commit bfc67b6
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ def unpacking_strings_disallowed(self, context: Context) -> None:
self.fail("Unpacking a string is disallowed", context)

def type_not_iterable(self, type: Type, context: Context) -> None:
self.fail('\'{}\' object is not iterable'.format(type), context)
self.fail('"{}" object is not iterable'.format(type), context)

def incompatible_operator_assignment(self, op: str,
context: Context) -> None:
Expand Down
10 changes: 5 additions & 5 deletions test-data/unit/check-inference.test
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,17 @@ main:6: error: Need more than 3 values to unpack (4 expected)
[case testInvalidRvalueTypeInInferredMultipleLvarDefinition]
import typing
def f() -> None:
a, b = f # E: 'def ()' object is not iterable
c, d = A() # E: '__main__.A' object is not iterable
a, b = f # E: "def ()" object is not iterable
c, d = A() # E: "__main__.A" object is not iterable
class A: pass
[builtins fixtures/for.pyi]
[out]

[case testInvalidRvalueTypeInInferredNestedTupleAssignment]
import typing
def f() -> None:
a1, (a2, b) = A(), f # E: 'def ()' object is not iterable
a3, (c, d) = A(), A() # E: '__main__.A' object is not iterable
a1, (a2, b) = A(), f # E: "def ()" object is not iterable
a3, (c, d) = A(), A() # E: "__main__.A" object is not iterable
class A: pass
[builtins fixtures/for.pyi]
[out]
Expand Down Expand Up @@ -1004,7 +1004,7 @@ main:4: error: Incompatible types in assignment (expression has type "A", variab
main:5: error: Incompatible types in assignment (expression has type "B", variable has type "C")
main:6: error: Incompatible types in assignment (expression has type "C", variable has type "A")
main:10: error: Need more than 2 values to unpack (3 expected)
main:12: error: '__main__.B' object is not iterable
main:12: error: "__main__.B" object is not iterable

[case testInferenceOfFor3]

Expand Down
4 changes: 2 additions & 2 deletions test-data/unit/check-modules.test
Original file line number Diff line number Diff line change
Expand Up @@ -1676,10 +1676,10 @@ reveal_type(n2.b) # N: Revealed type is 'builtins.str'
reveal_type(m3.a) # N: Revealed type is 'builtins.str'
reveal_type(n3.b) # N: Revealed type is 'builtins.str'

x, y = m # E: 'types.ModuleType' object is not iterable
x, y = m # E: "types.ModuleType" object is not iterable
x, y, z = m, n # E: Need more than 2 values to unpack (3 expected)
x, y = m, m, m # E: Too many values to unpack (2 expected, 3 provided)
x, (y, z) = m, n # E: 'types.ModuleType' object is not iterable
x, (y, z) = m, n # E: "types.ModuleType" object is not iterable
x, (y, z) = m, (n, n, n) # E: Too many values to unpack (2 expected, 3 provided)

[file m.py]
Expand Down
12 changes: 6 additions & 6 deletions test-data/unit/check-tuples.test
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ a, b = None, None # type: (A, B)

a1, b1 = a, a # type: (A, B) # E: Incompatible types in assignment (expression has type "A", variable has type "B")
a2, b2 = b, b # type: (A, B) # E: Incompatible types in assignment (expression has type "B", variable has type "A")
a3, b3 = a # type: (A, B) # E: '__main__.A' object is not iterable
a4, b4 = None # type: (A, B) # E: 'None' object is not iterable
a3, b3 = a # type: (A, B) # E: "__main__.A" object is not iterable
a4, b4 = None # type: (A, B) # E: "None" object is not iterable
a5, b5 = a, b, a # type: (A, B) # E: Too many values to unpack (2 expected, 3 provided)

ax, bx = a, b # type: (A, B)
Expand All @@ -420,9 +420,9 @@ class B: pass
a, b = None, None # type: (A, B)
def f(): pass

a, b = None # E: 'None' object is not iterable
a, b = a # E: '__main__.A' object is not iterable
a, b = f # E: 'def () -> Any' object is not iterable
a, b = None # E: "None" object is not iterable
a, b = a # E: "__main__.A" object is not iterable
a, b = f # E: "def () -> Any" object is not iterable

class A: pass
class B: pass
Expand Down Expand Up @@ -1468,5 +1468,5 @@ x9, y9, x10, y10, z5 = *points2, 1, *points2 # E: Contiguous iterable with same
() = [] # E: can't assign to ()

[case testAssignEmptyBogus]
() = 1 # E: 'Literal[1]?' object is not iterable
() = 1 # E: "Literal[1]?" object is not iterable
[builtins fixtures/tuple.pyi]
4 changes: 2 additions & 2 deletions test-data/unit/check-unions.test
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ reveal_type(d1) # N: Revealed type is 'Union[Any, builtins.float]'
reveal_type(d2) # N: Revealed type is 'Union[Any, builtins.float]'

e: Union[Any, Tuple[float, float], int]
(e1, e2) = e # E: 'builtins.int' object is not iterable
(e1, e2) = e # E: "builtins.int" object is not iterable
[builtins fixtures/tuple.pyi]

[case testUnionMultiassignNotJoin]
Expand Down Expand Up @@ -694,7 +694,7 @@ reveal_type(d) # N: Revealed type is 'builtins.list[builtins.int*]'
from typing import Union
bad: Union[int, str]

x, y = bad # E: 'builtins.int' object is not iterable \
x, y = bad # E: "builtins.int" object is not iterable \
# E: Unpacking a string is disallowed
reveal_type(x) # N: Revealed type is 'Any'
reveal_type(y) # N: Revealed type is 'Any'
Expand Down

0 comments on commit bfc67b6

Please sign in to comment.