Skip to content

Commit bfc67b6

Browse files
authored
Use double quotes in 'object is not iterable' error message (#10231)
1 parent dc08ab6 commit bfc67b6

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

mypy/messages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ def unpacking_strings_disallowed(self, context: Context) -> None:
754754
self.fail("Unpacking a string is disallowed", context)
755755

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

759759
def incompatible_operator_assignment(self, op: str,
760760
context: Context) -> None:

test-data/unit/check-inference.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,17 @@ main:6: error: Need more than 3 values to unpack (4 expected)
287287
[case testInvalidRvalueTypeInInferredMultipleLvarDefinition]
288288
import typing
289289
def f() -> None:
290-
a, b = f # E: 'def ()' object is not iterable
291-
c, d = A() # E: '__main__.A' object is not iterable
290+
a, b = f # E: "def ()" object is not iterable
291+
c, d = A() # E: "__main__.A" object is not iterable
292292
class A: pass
293293
[builtins fixtures/for.pyi]
294294
[out]
295295

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

10091009
[case testInferenceOfFor3]
10101010

test-data/unit/check-modules.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,10 +1676,10 @@ reveal_type(n2.b) # N: Revealed type is 'builtins.str'
16761676
reveal_type(m3.a) # N: Revealed type is 'builtins.str'
16771677
reveal_type(n3.b) # N: Revealed type is 'builtins.str'
16781678

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

16851685
[file m.py]

test-data/unit/check-tuples.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ a, b = None, None # type: (A, B)
405405

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

412412
ax, bx = a, b # type: (A, B)
@@ -420,9 +420,9 @@ class B: pass
420420
a, b = None, None # type: (A, B)
421421
def f(): pass
422422

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

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

14701470
[case testAssignEmptyBogus]
1471-
() = 1 # E: 'Literal[1]?' object is not iterable
1471+
() = 1 # E: "Literal[1]?" object is not iterable
14721472
[builtins fixtures/tuple.pyi]

test-data/unit/check-unions.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ reveal_type(d1) # N: Revealed type is 'Union[Any, builtins.float]'
556556
reveal_type(d2) # N: Revealed type is 'Union[Any, builtins.float]'
557557

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

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

697-
x, y = bad # E: 'builtins.int' object is not iterable \
697+
x, y = bad # E: "builtins.int" object is not iterable \
698698
# E: Unpacking a string is disallowed
699699
reveal_type(x) # N: Revealed type is 'Any'
700700
reveal_type(y) # N: Revealed type is 'Any'

0 commit comments

Comments
 (0)