Skip to content

Commit eb6f092

Browse files
authored
Use double quotes in error messages (#10511)
Changes the messages "Inconsistent use of * in function", "is a type variable and only valid in type context" and "Import of x ignored"
1 parent c3a600b commit eb6f092

12 files changed

+27
-27
lines changed

docs/source/running_mypy.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ accepts one of four string values:
348348
- ``error`` behaves in the same way as ``skip`` but is not quite as
349349
silent -- it will flag the import as an error, like this::
350350

351-
main.py:1: note: Import of 'mycode.bar' ignored
351+
main.py:1: note: Import of "mycode.bar" ignored
352352
main.py:1: note: (Using --follow-imports=error, module not passed on command line)
353353

354354
If you are starting a new codebase and plan on using type hints from

mypy/build.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,7 +2568,7 @@ def skipping_module(manager: BuildManager, line: int, caller_state: Optional[Sta
25682568
manager.errors.set_import_context(caller_state.import_context)
25692569
manager.errors.set_file(caller_state.xpath, caller_state.id)
25702570
manager.errors.report(line, 0,
2571-
"Import of '%s' ignored" % (id,),
2571+
'Import of "%s" ignored' % (id,),
25722572
severity='error')
25732573
manager.errors.report(line, 0,
25742574
"(Using --follow-imports=error, module not passed on command line)",
@@ -2584,7 +2584,7 @@ def skipping_ancestor(manager: BuildManager, id: str, path: str, ancestor_for: '
25842584
# so we'd need to cache the decision.
25852585
manager.errors.set_import_context([])
25862586
manager.errors.set_file(ancestor_for.xpath, ancestor_for.id)
2587-
manager.errors.report(-1, -1, "Ancestor package '%s' ignored" % (id,),
2587+
manager.errors.report(-1, -1, 'Ancestor package "%s" ignored' % (id,),
25882588
severity='error', only_once=True)
25892589
manager.errors.report(-1, -1,
25902590
"(Using --follow-imports=error, submodule passed on command line)",

mypy/semanal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3542,8 +3542,8 @@ def visit_name_expr(self, expr: NameExpr) -> None:
35423542
def bind_name_expr(self, expr: NameExpr, sym: SymbolTableNode) -> None:
35433543
"""Bind name expression to a symbol table node."""
35443544
if isinstance(sym.node, TypeVarExpr) and self.tvar_scope.get_binding(sym):
3545-
self.fail("'{}' is a type variable and only valid in type "
3546-
"context".format(expr.name), expr)
3545+
self.fail('"{}" is a type variable and only valid in type '
3546+
'context'.format(expr.name), expr)
35473547
elif isinstance(sym.node, PlaceholderNode):
35483548
self.process_placeholder(expr.name, 'name', expr)
35493549
else:

test-data/unit/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Add the test in this format anywhere in the file:
2323
b: str = 5 # E: Incompatible types in assignment (expression has type "int", variable has type "str")
2424

2525
zzz: int
26-
zzz: str # E: Name 'zzz' already defined
26+
zzz: str # E: Name "zzz" already defined
2727

2828
- no code here is executed, just type checked
2929
- optional `# flags: ` indicates which flags to use for this unit test

test-data/unit/check-flags.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ x + ""
461461
[file mod.py]
462462
deliberate syntax error
463463
[out]
464-
main:2: error: Import of 'mod' ignored
464+
main:2: error: Import of "mod" ignored
465465
main:2: note: (Using --follow-imports=error, module not passed on command line)
466466

467467
[case testIgnoreMissingImportsFalse]

test-data/unit/check-incremental.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,10 +1789,10 @@ import a
17891789
[file a.py.2]
17901790
//
17911791
[out1]
1792-
main:2: error: Import of 'a' ignored
1792+
main:2: error: Import of "a" ignored
17931793
main:2: note: (Using --follow-imports=error, module not passed on command line)
17941794
[out2]
1795-
main:2: error: Import of 'a' ignored
1795+
main:2: error: Import of "a" ignored
17961796
main:2: note: (Using --follow-imports=error, module not passed on command line)
17971797

17981798
[case testIncrementalFollowImportsVariable]

test-data/unit/check-modules.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,7 @@ import mod
10541054
[file mod.py]
10551055
[builtins fixtures/module.pyi]
10561056
[out]
1057-
tmp/main.py:1: error: Import of 'mod' ignored
1057+
tmp/main.py:1: error: Import of "mod" ignored
10581058
tmp/main.py:1: note: (Using --follow-imports=error, module not passed on command line)
10591059

10601060
[case testAncestorSuppressedWhileAlmostSilent]
@@ -1064,7 +1064,7 @@ tmp/main.py:1: note: (Using --follow-imports=error, module not passed on command
10641064
[file foo/__init__.py]
10651065
[builtins fixtures/module.pyi]
10661066
[out]
1067-
tmp/foo/bar.py: error: Ancestor package 'foo' ignored
1067+
tmp/foo/bar.py: error: Ancestor package "foo" ignored
10681068
tmp/foo/bar.py: note: (Using --follow-imports=error, submodule passed on command line)
10691069

10701070
[case testStubImportNonStubWhileSilent]

test-data/unit/cmdline.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ follow_imports = error
413413
[file a.py]
414414
/ # No error reported
415415
[out]
416-
main.py:1: error: Import of 'a' ignored
416+
main.py:1: error: Import of "a" ignored
417417
main.py:1: note: (Using --follow-imports=error, module not passed on command line)
418418
main.py:2: note: Revealed type is "Any"
419419
main.py:4: note: Revealed type is "Any"
@@ -451,7 +451,7 @@ bla bla
451451
bla bla
452452
[out]
453453
normal.py:2: error: Unsupported operand types for + ("int" and "str")
454-
main.py:4: error: Import of 'error' ignored
454+
main.py:4: error: Import of "error" ignored
455455
main.py:4: note: (Using --follow-imports=error, module not passed on command line)
456456
main.py:5: note: Revealed type is "builtins.int"
457457
main.py:6: note: Revealed type is "builtins.int"
@@ -832,7 +832,7 @@ follow_imports_for_stubs = True
832832
import math
833833
math.frobnicate()
834834
[out]
835-
main.py:1: error: Import of 'math' ignored
835+
main.py:1: error: Import of "math" ignored
836836
main.py:1: note: (Using --follow-imports=error, module not passed on command line)
837837

838838
[case testFollowImportStubs2]

test-data/unit/daemon.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Daemon started
184184
$ dmypy check foo.py bar.py
185185
$ dmypy recheck
186186
$ dmypy recheck --update foo.py --remove bar.py sir_not_appearing_in_this_film.py
187-
foo.py:1: error: Import of 'bar' ignored
187+
foo.py:1: error: Import of "bar" ignored
188188
foo.py:1: note: (Using --follow-imports=error, module not passed on command line)
189189
== Return code: 1
190190
$ dmypy recheck --update bar.py

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,10 +1828,10 @@ x = 1
18281828
[file c.py.2]
18291829
x = '2'
18301830
[out]
1831-
a.py:2: error: Import of 'b' ignored
1831+
a.py:2: error: Import of "b" ignored
18321832
a.py:2: note: (Using --follow-imports=error, module not passed on command line)
18331833
==
1834-
a.py:2: error: Import of 'b' ignored
1834+
a.py:2: error: Import of "b" ignored
18351835
a.py:2: note: (Using --follow-imports=error, module not passed on command line)
18361836

18371837
[case testErrorButDontIgnore2]
@@ -1848,7 +1848,7 @@ x = 1
18481848
x = '2'
18491849
[out]
18501850
==
1851-
a.py:2: error: Import of 'b' ignored
1851+
a.py:2: error: Import of "b" ignored
18521852
a.py:2: note: (Using --follow-imports=error, module not passed on command line)
18531853

18541854
-- TODO: This test fails because p.b does not depend on p (#4847)
@@ -1868,7 +1868,7 @@ x = 1
18681868
x = '2'
18691869
[out]
18701870
==
1871-
p/b.py: error: Ancestor package 'p' ignored
1871+
p/b.py: error: Ancestor package "p" ignored
18721872
p/b.py: note: (Using --follow-imports=error, submodule passed on command line)
18731873

18741874
[case testErrorButDontIgnore4]
@@ -1886,7 +1886,7 @@ x = 1
18861886
[delete z.py.2]
18871887
[out]
18881888
==
1889-
p/b.py: error: Ancestor package 'p' ignored
1889+
p/b.py: error: Ancestor package "p" ignored
18901890
p/b.py: note: (Using --follow-imports=error, submodule passed on command line)
18911891
p/b.py:1: error: Cannot find implementation or library stub for module named "z"
18921892
p/b.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports

test-data/unit/parse-errors.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ def f(x): # type: (*X) -> Y
258258
def g(*x): # type: (X) -> Y
259259
pass
260260
[out]
261-
file:1: error: Inconsistent use of '*' in function signature
262-
file:3: error: Inconsistent use of '*' in function signature
261+
file:1: error: Inconsistent use of "*" in function signature
262+
file:3: error: Inconsistent use of "*" in function signature
263263

264264
[case testCommentFunctionAnnotationVarArgMispatch2-skip]
265265
# see mypy issue #1997
@@ -268,10 +268,10 @@ def f(*x, **y): # type: (**X, *Y) -> Z
268268
def g(*x, **y): # type: (*X, *Y) -> Z
269269
pass
270270
[out]
271-
file:1: error: Inconsistent use of '*' in function signature
271+
file:1: error: Inconsistent use of "*" in function signature
272272
file:3: error: syntax error in type comment
273-
file:3: error: Inconsistent use of '*' in function signature
274-
file:3: error: Inconsistent use of '**' in function signature
273+
file:3: error: Inconsistent use of "*" in function signature
274+
file:3: error: Inconsistent use of "**" in function signature
275275

276276
[case testPrintStatementInPython35]
277277
# flags: --python-version 3.5

test-data/unit/semanal-errors.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,8 @@ class c(Generic[t]):
533533
def f(self) -> None: x = t
534534
def f(y: t): x = t
535535
[out]
536-
main:4: error: 't' is a type variable and only valid in type context
537-
main:5: error: 't' is a type variable and only valid in type context
536+
main:4: error: "t" is a type variable and only valid in type context
537+
main:5: error: "t" is a type variable and only valid in type context
538538

539539
[case testMissingSelf]
540540
import typing

0 commit comments

Comments
 (0)