Skip to content

Commit b049e6a

Browse files
authored
Use double quotes errors in 'dont mix' and 'has no attributes' (#10296)
1 parent c5e4e0f commit b049e6a

21 files changed

+76
-76
lines changed

docs/source/class_basics.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ initialized within the class. Mypy infers the types of attributes:
2121
2222
a = A(1)
2323
a.x = 2 # OK!
24-
a.y = 3 # Error: 'A' has no attribute 'y'
24+
a.y = 3 # Error: "A" has no attribute "y"
2525
2626
This is a bit like each class having an implicitly defined
2727
:py:data:`__slots__ <object.__slots__>` attribute. This is only enforced during type

docs/source/error_code_list.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ target module can be found):
3636

3737
.. code-block:: python
3838
39-
# Error: Module 'os' has no attribute 'non_existent' [attr-defined]
39+
# Error: Module "os" has no attribute "non_existent" [attr-defined]
4040
from os import non_existent
4141
4242
A reference to a missing attribute is given the ``Any`` type. In the

mypy/plugins/attrs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def _determine_eq_order(ctx: 'mypy.plugin.ClassDefContext') -> bool:
212212
order = _get_decorator_optional_bool_argument(ctx, 'order')
213213

214214
if cmp is not None and any((eq is not None, order is not None)):
215-
ctx.api.fail("Don't mix `cmp` with `eq' and `order`", ctx.reason)
215+
ctx.api.fail('Don\'t mix "cmp" with "eq" and "order"', ctx.reason)
216216

217217
# cmp takes precedence due to bw-compatibility.
218218
if cmp is not None:
@@ -226,7 +226,7 @@ def _determine_eq_order(ctx: 'mypy.plugin.ClassDefContext') -> bool:
226226
order = eq
227227

228228
if eq is False and order is True:
229-
ctx.api.fail("eq must be True if order is True", ctx.reason)
229+
ctx.api.fail('eq must be True if order is True', ctx.reason)
230230

231231
return order
232232

mypy/semanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ def report_missing_module_attribute(
18561856
# is incomplete. Defer the current target.
18571857
self.mark_incomplete(imported_id, context)
18581858
return
1859-
message = "Module '{}' has no attribute '{}'".format(import_id, source_id)
1859+
message = 'Module "{}" has no attribute "{}"'.format(import_id, source_id)
18601860
# Suggest alternatives, if any match is found.
18611861
module = self.modules.get(import_id)
18621862
if module:

test-data/unit/check-attr.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ class DeprecatedTrue:
282282
class DeprecatedFalse:
283283
...
284284

285-
@attrs(cmp=False, eq=True) # E: Don't mix `cmp` with `eq' and `order`
285+
@attrs(cmp=False, eq=True) # E: Don't mix "cmp" with "eq" and "order"
286286
class Mixed:
287287
...
288288

test-data/unit/check-columns.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def f(x: object, n: int, s: str) -> None:
125125
[case testColumnHasNoAttribute]
126126
import m
127127
if int():
128-
from m import foobaz # E:5: Module 'm' has no attribute 'foobaz'; maybe "foobar"?
128+
from m import foobaz # E:5: Module "m" has no attribute "foobaz"; maybe "foobar"?
129129
1 .x # E:1: "int" has no attribute "x"
130130
(m.foobaz()) # E:2: Module has no attribute "foobaz"; maybe "foobar"?
131131

test-data/unit/check-errorcodes.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import m
77
m.x # E: Module has no attribute "x" [attr-defined]
88
'x'.foobar # E: "str" has no attribute "foobar" [attr-defined]
9-
from m import xx # E: Module 'm' has no attribute 'xx' [attr-defined]
10-
from m import think # E: Module 'm' has no attribute 'think'; maybe "thing"? [attr-defined]
9+
from m import xx # E: Module "m" has no attribute "xx" [attr-defined]
10+
from m import think # E: Module "m" has no attribute "think"; maybe "thing"? [attr-defined]
1111
for x in 1: # E: "int" has no attribute "__iter__" (not iterable) [attr-defined]
1212
pass
1313
[file m.py]
@@ -504,7 +504,7 @@ from defusedxml import xyz # E: Cannot find implementation or library stub for
504504
from nonexistent import foobar # E: Cannot find implementation or library stub for module named "nonexistent" [import]
505505
import nonexistent2 # E: Cannot find implementation or library stub for module named "nonexistent2" [import]
506506
from nonexistent3 import * # E: Cannot find implementation or library stub for module named "nonexistent3" [import]
507-
from pkg import bad # E: Module 'pkg' has no attribute 'bad' [attr-defined]
507+
from pkg import bad # E: Module "pkg" has no attribute "bad" [attr-defined]
508508
from pkg.bad2 import bad3 # E: Cannot find implementation or library stub for module named "pkg.bad2" [import]
509509
[file pkg/__init__.py]
510510

test-data/unit/check-flags.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ implicit_reexport = True
13031303
\[mypy-other_module_2]
13041304
implicit_reexport = False
13051305
[out]
1306-
main:2: error: Module 'other_module_2' has no attribute 'a'
1306+
main:2: error: Module "other_module_2" has no attribute "a"
13071307

13081308
[case testImplicitAnyOKForNoArgs]
13091309
# flags: --disallow-any-generics --show-column-numbers

test-data/unit/check-incomplete-fixture.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@ m.x # E: "object" has no attribute "x"
1616
from typing import List
1717
def f(x: List[int]) -> None: pass
1818
[out]
19-
main:1: error: Module 'typing' has no attribute 'List'
19+
main:1: error: Module "typing" has no attribute "List"
2020
main:1: note: Maybe your test fixture does not define "builtins.list"?
2121
main:1: note: Consider adding [builtins fixtures/list.pyi] to your test description
2222

2323
[case testDictMissingFromStubs]
2424
from typing import Dict
2525
def f(x: Dict[int]) -> None: pass
2626
[out]
27-
main:1: error: Module 'typing' has no attribute 'Dict'
27+
main:1: error: Module "typing" has no attribute "Dict"
2828
main:1: note: Maybe your test fixture does not define "builtins.dict"?
2929
main:1: note: Consider adding [builtins fixtures/dict.pyi] to your test description
3030

3131
[case testSetMissingFromStubs]
3232
from typing import Set
3333
def f(x: Set[int]) -> None: pass
3434
[out]
35-
main:1: error: Module 'typing' has no attribute 'Set'
35+
main:1: error: Module "typing" has no attribute "Set"
3636
main:1: note: Maybe your test fixture does not define "builtins.set"?
3737
main:1: note: Consider adding [builtins fixtures/set.pyi] to your test description
3838

test-data/unit/check-incremental.test

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,9 +1821,9 @@ class C:
18211821
A = NamedTuple('A', [('x', int), ('y', int)])
18221822
[builtins fixtures/tuple.pyi]
18231823
[out1]
1824-
main:1: error: Module 'ntcrash' has no attribute 'nope'
1824+
main:1: error: Module "ntcrash" has no attribute "nope"
18251825
[out2]
1826-
main:1: error: Module 'ntcrash' has no attribute 'nope'
1826+
main:1: error: Module "ntcrash" has no attribute "nope"
18271827

18281828
[case testIncrementalNamedTupleInMethod2]
18291829
from ntcrash import nope
@@ -1835,9 +1835,9 @@ class C:
18351835
A = NamedTuple('A', [('x', int), ('y', int)])
18361836
[builtins fixtures/tuple.pyi]
18371837
[out1]
1838-
main:1: error: Module 'ntcrash' has no attribute 'nope'
1838+
main:1: error: Module "ntcrash" has no attribute "nope"
18391839
[out2]
1840-
main:1: error: Module 'ntcrash' has no attribute 'nope'
1840+
main:1: error: Module "ntcrash" has no attribute "nope"
18411841

18421842
[case testIncrementalNamedTupleInMethod3]
18431843
from ntcrash import nope
@@ -1850,9 +1850,9 @@ class C:
18501850
A = NamedTuple('A', [('x', int), ('y', int)])
18511851
[builtins fixtures/tuple.pyi]
18521852
[out1]
1853-
main:1: error: Module 'ntcrash' has no attribute 'nope'
1853+
main:1: error: Module "ntcrash" has no attribute "nope"
18541854
[out2]
1855-
main:1: error: Module 'ntcrash' has no attribute 'nope'
1855+
main:1: error: Module "ntcrash" has no attribute "nope"
18561856

18571857
[case testIncrementalTypedDictInMethod]
18581858
from tdcrash import nope
@@ -1863,9 +1863,9 @@ class C:
18631863
A = TypedDict('A', {'x': int, 'y': int})
18641864
[builtins fixtures/dict.pyi]
18651865
[out1]
1866-
main:1: error: Module 'tdcrash' has no attribute 'nope'
1866+
main:1: error: Module "tdcrash" has no attribute "nope"
18671867
[out2]
1868-
main:1: error: Module 'tdcrash' has no attribute 'nope'
1868+
main:1: error: Module "tdcrash" has no attribute "nope"
18691869

18701870
[case testIncrementalTypedDictInMethod2]
18711871
from tdcrash import nope
@@ -1877,9 +1877,9 @@ class C:
18771877
A = TypedDict('A', {'x': int, 'y': int})
18781878
[builtins fixtures/dict.pyi]
18791879
[out1]
1880-
main:1: error: Module 'tdcrash' has no attribute 'nope'
1880+
main:1: error: Module "tdcrash" has no attribute "nope"
18811881
[out2]
1882-
main:1: error: Module 'tdcrash' has no attribute 'nope'
1882+
main:1: error: Module "tdcrash" has no attribute "nope"
18831883

18841884
[case testIncrementalTypedDictInMethod3]
18851885
from tdcrash import nope
@@ -1892,9 +1892,9 @@ class C:
18921892
A = TypedDict('A', {'x': int, 'y': int})
18931893
[builtins fixtures/dict.pyi]
18941894
[out1]
1895-
main:1: error: Module 'tdcrash' has no attribute 'nope'
1895+
main:1: error: Module "tdcrash" has no attribute "nope"
18961896
[out2]
1897-
main:1: error: Module 'tdcrash' has no attribute 'nope'
1897+
main:1: error: Module "tdcrash" has no attribute "nope"
18981898

18991899
[case testIncrementalNewTypeInMethod]
19001900
from ntcrash import nope
@@ -1914,9 +1914,9 @@ def f() -> None:
19141914

19151915
[builtins fixtures/dict.pyi]
19161916
[out1]
1917-
main:1: error: Module 'ntcrash' has no attribute 'nope'
1917+
main:1: error: Module "ntcrash" has no attribute "nope"
19181918
[out2]
1919-
main:1: error: Module 'ntcrash' has no attribute 'nope'
1919+
main:1: error: Module "ntcrash" has no attribute "nope"
19201920

19211921
[case testIncrementalInnerClassAttrInMethod]
19221922
import crash
@@ -2225,9 +2225,9 @@ from b import x
22252225
1 + 1
22262226
[out]
22272227
[out2]
2228-
tmp/b.py:1: error: Module 'c' has no attribute 'x'
2228+
tmp/b.py:1: error: Module "c" has no attribute "x"
22292229
[out3]
2230-
tmp/b.py:1: error: Module 'c' has no attribute 'x'
2230+
tmp/b.py:1: error: Module "c" has no attribute "x"
22312231

22322232
[case testCacheDeletedAfterErrorsFound2]
22332233

@@ -2284,9 +2284,9 @@ from b import x
22842284
1 + 1
22852285
[out]
22862286
[out2]
2287-
tmp/c.py:1: error: Module 'd' has no attribute 'x'
2287+
tmp/c.py:1: error: Module "d" has no attribute "x"
22882288
[out3]
2289-
tmp/c.py:1: error: Module 'd' has no attribute 'x'
2289+
tmp/c.py:1: error: Module "d" has no attribute "x"
22902290

22912291
[case testNoCrashOnDeletedWithCacheOnCmdline]
22922292
# cmd: mypy -m nonexistent
@@ -4572,10 +4572,10 @@ B = List[A]
45724572

45734573
[builtins fixtures/list.pyi]
45744574
[out]
4575-
tmp/lib.pyi:4: error: Module 'other' has no attribute 'B'
4575+
tmp/lib.pyi:4: error: Module "other" has no attribute "B"
45764576
tmp/other.pyi:3: error: Cannot resolve name "B" (possible cyclic definition)
45774577
[out2]
4578-
tmp/lib.pyi:4: error: Module 'other' has no attribute 'B'
4578+
tmp/lib.pyi:4: error: Module "other" has no attribute "B"
45794579
tmp/other.pyi:3: error: Cannot resolve name "B" (possible cyclic definition)
45804580
tmp/a.py:3: note: Revealed type is "builtins.list[Any]"
45814581

test-data/unit/check-modules-case.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
-- Type checker test cases dealing with modules and imports on case-insensitive filesystems.
22

33
[case testCaseSensitivityDir]
4-
from a import B # E: Module 'a' has no attribute 'B'
4+
from a import B # E: Module "a" has no attribute "B"
55

66
[file a/__init__.py]
77
[file a/b/__init__.py]
88

99
[case testCaseInsensitivityDir]
1010
# flags: --config-file tmp/mypy.ini
1111

12-
from a import B # E: Module 'a' has no attribute 'B'
12+
from a import B # E: Module "a" has no attribute "B"
1313
from other import x
1414
reveal_type(x) # N: Revealed type is "builtins.int"
1515

test-data/unit/check-modules.test

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,7 @@ from foo import B
10441044
class C(B):
10451045
pass
10461046
[out]
1047-
tmp/bar.py:1: error: Module 'foo' has no attribute 'B'
1047+
tmp/bar.py:1: error: Module "foo" has no attribute "B"
10481048

10491049
[case testImportSuppressedWhileAlmostSilent]
10501050
# cmd: mypy -m main
@@ -1817,8 +1817,8 @@ m = n # E: Cannot assign multiple modules to name 'm' without explicit 'types.M
18171817
[builtins fixtures/module.pyi]
18181818

18191819
[case testNoReExportFromStubs]
1820-
from stub import Iterable # E: Module 'stub' has no attribute 'Iterable'
1821-
from stub import D # E: Module 'stub' has no attribute 'D'
1820+
from stub import Iterable # E: Module "stub" has no attribute "Iterable"
1821+
from stub import D # E: Module "stub" has no attribute "D"
18221822
from stub import C
18231823

18241824
c = C()
@@ -1912,7 +1912,7 @@ class C:
19121912

19131913
[case testNoReExportChildStubs]
19141914
import mod
1915-
from mod import C, D # E: Module 'mod' has no attribute 'C'
1915+
from mod import C, D # E: Module "mod" has no attribute "C"
19161916

19171917
reveal_type(mod.x) # N: Revealed type is "mod.submod.C"
19181918
mod.C # E: Module has no attribute "C"
@@ -1930,7 +1930,7 @@ class D:
19301930
[builtins fixtures/module.pyi]
19311931

19321932
[case testNoReExportNestedStub]
1933-
from stub import substub # E: Module 'stub' has no attribute 'substub'
1933+
from stub import substub # E: Module "stub" has no attribute "substub"
19341934

19351935
[file stub.pyi]
19361936
import substub
@@ -2074,7 +2074,7 @@ def __getattr__(name: str) -> int: ...
20742074

20752075
[case testModuleLevelGetattrImportFromNotStub36]
20762076
# flags: --python-version 3.6
2077-
from non_stub import name # E: Module 'non_stub' has no attribute 'name'
2077+
from non_stub import name # E: Module "non_stub" has no attribute "name"
20782078
reveal_type(name) # N: Revealed type is "Any"
20792079

20802080
[file non_stub.py]
@@ -2814,10 +2814,10 @@ CustomDict = TypedDict(
28142814
[builtins fixtures/tuple.pyi]
28152815

28162816
[case testNoReExportFromMissingStubs]
2817-
from stub import a # E: Module 'stub' has no attribute 'a'
2817+
from stub import a # E: Module "stub" has no attribute "a"
28182818
from stub import b
2819-
from stub import c # E: Module 'stub' has no attribute 'c'
2820-
from stub import d # E: Module 'stub' has no attribute 'd'
2819+
from stub import c # E: Module "stub" has no attribute "c"
2820+
from stub import d # E: Module "stub" has no attribute "d"
28212821

28222822
[file stub.pyi]
28232823
from mystery import a, b as b, c as d

test-data/unit/check-newsemanal.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ tmp/a.py:4: error: "B" not callable
6767
[case testNewAnalyzerTypeAnnotationCycle3]
6868
import b
6969
[file a.py]
70-
from b import bad # E: Module 'b' has no attribute 'bad'; maybe "bad2"?
70+
from b import bad # E: Module "b" has no attribute "bad"; maybe "bad2"?
7171
[file b.py]
72-
from a import bad2 # E: Module 'a' has no attribute 'bad2'; maybe "bad"?
72+
from a import bad2 # E: Module "a" has no attribute "bad2"; maybe "bad"?
7373

7474
[case testNewAnalyzerTypeAnnotationCycle4]
7575
import b
7676
[file a.py]
77-
from b import bad # E: Module 'b' has no attribute 'bad'
77+
from b import bad # E: Module "b" has no attribute "bad"
7878
[file b.py]
7979
# TODO: Could we generate an error here as well?
8080
from a import bad

test-data/unit/fine-grained-blockers.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ class A:
392392
main:1: error: Cannot find implementation or library stub for module named "a"
393393
main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
394394
==
395-
main:1: error: Module 'a' has no attribute 'A'
395+
main:1: error: Module "a" has no attribute "A"
396396

397397
[case testFixingBlockingErrorBringsInAnotherModuleWithBlocker]
398398
import a

test-data/unit/fine-grained-cycles.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def h() -> None:
172172

173173
[out]
174174
==
175-
a.py:1: error: Module 'b' has no attribute 'C'
175+
a.py:1: error: Module "b" has no attribute "C"
176176

177177
[case testReferenceToTypeThroughCycleAndReplaceWithFunction]
178178

test-data/unit/fine-grained-follow-imports.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ from p import m
501501
main.py:1: error: Cannot find implementation or library stub for module named "p"
502502
main.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
503503
==
504-
main.py:1: error: Module 'p' has no attribute 'm'
504+
main.py:1: error: Module "p" has no attribute "m"
505505
==
506506
p/m.py:1: error: "str" not callable
507507

test-data/unit/fine-grained-modules.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ from p import q
402402
[file p/q.py.3]
403403
[out]
404404
==
405-
main:1: error: Module 'p' has no attribute 'q'
405+
main:1: error: Module "p" has no attribute "q"
406406
-- TODO: The following messages are different compared to non-incremental mode
407407
main:1: error: Cannot find implementation or library stub for module named "p.q"
408408
main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
@@ -1474,7 +1474,7 @@ from c import *
14741474
[file c.py.2]
14751475
def f(x: int) -> None: pass
14761476
[out]
1477-
main:1: error: Module 'b' has no attribute 'f'
1477+
main:1: error: Module "b" has no attribute "f"
14781478
==
14791479
main:2: error: Missing positional argument "x" in call to "f"
14801480

@@ -1523,7 +1523,7 @@ from p.c import *
15231523
[file p/c.py.2]
15241524
def f(x: int) -> None: pass
15251525
[out]
1526-
main:1: error: Module 'p.b' has no attribute 'f'
1526+
main:1: error: Module "p.b" has no attribute "f"
15271527
==
15281528
main:2: error: Missing positional argument "x" in call to "f"
15291529

@@ -1551,7 +1551,7 @@ def f() -> None: pass
15511551
[file c.py.2]
15521552
[out]
15531553
==
1554-
main:1: error: Module 'b' has no attribute 'f'
1554+
main:1: error: Module "b" has no attribute "f"
15551555

15561556
[case testImportStarRemoveDependency2]
15571557
from b import *

0 commit comments

Comments
 (0)