Skip to content

Commit de6fd6a

Browse files
authored
Double quotes in errors Source file found twice, Duplicate module named, Setting "strict" not supported, bound by an outer class and cannot subclass (#10513)
1 parent eb6f092 commit de6fd6a

9 files changed

+23
-23
lines changed

mypy/build.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2799,7 +2799,7 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,
27992799
manager.errors.set_file(st.xpath, st.id)
28002800
manager.errors.report(
28012801
-1, -1,
2802-
"Duplicate module named '%s' (also at '%s')" % (st.id, graph[st.id].xpath),
2802+
'Duplicate module named "%s" (also at "%s")' % (st.id, graph[st.id].xpath),
28032803
blocker=True,
28042804
)
28052805
manager.errors.report(
@@ -2869,8 +2869,8 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,
28692869
if newst_path in seen_files:
28702870
manager.errors.report(
28712871
-1, 0,
2872-
"Source file found twice under different module names: "
2873-
"'{}' and '{}'".format(seen_files[newst_path].id, newst.id),
2872+
'Source file found twice under different module names: '
2873+
'"{}" and "{}"'.format(seen_files[newst_path].id, newst.id),
28742874
blocker=True)
28752875
manager.errors.raise_error()
28762876

mypy/config_parser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,9 @@ def set_strict_flags() -> None:
525525
errors.append((lineno, "Reports not supported in inline configuration"))
526526
if strict_found:
527527
errors.append((lineno,
528-
"Setting 'strict' not supported in inline configuration: specify it in "
529-
"a configuration file instead, or set individual inline flags "
530-
"(see 'mypy -h' for the list of flags enabled in strict mode)"))
528+
'Setting "strict" not supported in inline configuration: specify it in '
529+
'a configuration file instead, or set individual inline flags '
530+
'(see "mypy -h" for the list of flags enabled in strict mode)'))
531531

532532
sections.update(new_sections)
533533

mypy/semanal.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,14 +1499,14 @@ def configure_base_classes(self,
14991499
base_types.append(actual_base)
15001500
elif isinstance(base, Instance):
15011501
if base.type.is_newtype:
1502-
self.fail("Cannot subclass NewType", defn)
1502+
self.fail('Cannot subclass "NewType"', defn)
15031503
base_types.append(base)
15041504
elif isinstance(base, AnyType):
15051505
if self.options.disallow_subclassing_any:
15061506
if isinstance(base_expr, (NameExpr, MemberExpr)):
1507-
msg = "Class cannot subclass '{}' (has type 'Any')".format(base_expr.name)
1507+
msg = 'Class cannot subclass "{}" (has type "Any")'.format(base_expr.name)
15081508
else:
1509-
msg = "Class cannot subclass value of type 'Any'"
1509+
msg = 'Class cannot subclass value of type "Any"'
15101510
self.fail(msg, base_expr)
15111511
info.fallback_to_any = True
15121512
else:

mypy/typeanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ def bind_function_type_variables(
934934
defs = [] # type: List[TypeVarLikeDef]
935935
for name, tvar in typevars:
936936
if not self.tvar_scope.allow_binding(tvar.fullname):
937-
self.fail("Type variable '{}' is bound by an outer class".format(name), defn)
937+
self.fail('Type variable "{}" is bound by an outer class'.format(name), defn)
938938
self.tvar_scope.bind_new(name, tvar)
939939
binding = self.tvar_scope.get_binding(tvar.fullname)
940940
assert binding is not None

test-data/unit/check-flags.test

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,15 @@ def f() -> None: pass
190190
# flags: --disallow-subclassing-any
191191
from typing import Any
192192
FakeClass = None # type: Any
193-
class Foo(FakeClass): pass # E: Class cannot subclass 'FakeClass' (has type 'Any')
193+
class Foo(FakeClass): pass # E: Class cannot subclass "FakeClass" (has type "Any")
194194
[out]
195195

196196
[case testSubclassingAnyMultipleBaseClasses]
197197
# flags: --disallow-subclassing-any
198198
from typing import Any
199199
FakeClass = None # type: Any
200200
class ActualClass: pass
201-
class Foo(ActualClass, FakeClass): pass # E: Class cannot subclass 'FakeClass' (has type 'Any')
201+
class Foo(ActualClass, FakeClass): pass # E: Class cannot subclass "FakeClass" (has type "Any")
202202
[out]
203203

204204
[case testSubclassingAnySilentImports]
@@ -213,7 +213,7 @@ class Foo(BaseClass): pass
213213
class BaseClass: pass
214214

215215
[out]
216-
tmp/main.py:2: error: Class cannot subclass 'BaseClass' (has type 'Any')
216+
tmp/main.py:2: error: Class cannot subclass "BaseClass" (has type "Any")
217217

218218
[case testSubclassingAnySilentImports2]
219219
# flags: --disallow-subclassing-any --follow-imports=skip
@@ -227,7 +227,7 @@ class Foo(ignored_module.BaseClass): pass
227227
class BaseClass: pass
228228

229229
[out]
230-
tmp/main.py:2: error: Class cannot subclass 'BaseClass' (has type 'Any')
230+
tmp/main.py:2: error: Class cannot subclass "BaseClass" (has type "Any")
231231

232232
[case testWarnNoReturnIgnoresTrivialFunctions]
233233
# flags: --warn-no-return
@@ -871,7 +871,7 @@ main:5: error: Argument 1 to "foo" becomes "Callable[[], Any]" due to an unfollo
871871
# flags: --ignore-missing-imports --disallow-any-unimported --disallow-subclassing-any
872872
from typing import Any
873873

874-
class C(Any): # E: Class cannot subclass 'Any' (has type 'Any')
874+
class C(Any): # E: Class cannot subclass "Any" (has type "Any")
875875
pass
876876

877877
[case testDisallowImplicitAnyVarDeclaration]
@@ -1797,7 +1797,7 @@ from typing import Any
17971797

17981798
x = None # type: Any
17991799

1800-
class ShouldNotBeFine(x): ... # E: Class cannot subclass 'x' (has type 'Any')
1800+
class ShouldNotBeFine(x): ... # E: Class cannot subclass "x" (has type "Any")
18011801

18021802
[file mypy.ini]
18031803
\[mypy]
@@ -1823,7 +1823,7 @@ from typing import Any
18231823

18241824
x = None # type: Any
18251825

1826-
class ShouldNotBeFine(x): ... # E: Class cannot subclass 'x' (has type 'Any')
1826+
class ShouldNotBeFine(x): ... # E: Class cannot subclass "x" (has type "Any")
18271827

18281828
[file pyproject.toml]
18291829
\[tool.mypy]

test-data/unit/check-generics.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ T = TypeVar('T')
15021502
class Outer(Generic[T]):
15031503
class Inner:
15041504
x: T # E: Invalid type "__main__.T"
1505-
def f(self, x: T) -> T: ... # E: Type variable 'T' is bound by an outer class
1505+
def f(self, x: T) -> T: ... # E: Type variable "T" is bound by an outer class
15061506
def g(self) -> None:
15071507
y: T # E: Invalid type "__main__.T"
15081508

test-data/unit/check-inline-config.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,4 @@ main:1: error: Unrecognized option: skip_file = True
161161
[case testInlineStrict]
162162
# mypy: strict
163163
[out]
164-
main:1: error: Setting 'strict' not supported in inline configuration: specify it in a configuration file instead, or set individual inline flags (see 'mypy -h' for the list of flags enabled in strict mode)
164+
main:1: error: Setting "strict" not supported in inline configuration: specify it in a configuration file instead, or set individual inline flags (see "mypy -h" for the list of flags enabled in strict mode)

test-data/unit/check-newtype.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ a = 3 # type: UserId # E: Incompatible types in assignment (expression has typ
338338
from typing import NewType
339339
class A: pass
340340
B = NewType('B', A)
341-
class C(B): pass # E: Cannot subclass NewType
341+
class C(B): pass # E: Cannot subclass "NewType"
342342
[out]
343343

344344
[case testCannotUseNewTypeWithProtocols]

test-data/unit/cmdline.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ undef
5858
[file dir/subdir/a.py]
5959
undef
6060
[out]
61-
dir/a.py: error: Duplicate module named 'a' (also at 'dir/subdir/a.py')
61+
dir/a.py: error: Duplicate module named "a" (also at "dir/subdir/a.py")
6262
dir/a.py: note: Are you missing an __init__.py? Alternatively, consider using --exclude to avoid checking one of them.
6363
== Return code: 2
6464

@@ -124,7 +124,7 @@ mypy: can't decode file 'a.py': unknown encoding: uft-8
124124
[file two/mod/__init__.py]
125125
# type: ignore
126126
[out]
127-
two/mod/__init__.py: error: Duplicate module named 'mod' (also at 'one/mod/__init__.py')
127+
two/mod/__init__.py: error: Duplicate module named "mod" (also at "one/mod/__init__.py")
128128
two/mod/__init__.py: note: Are you missing an __init__.py? Alternatively, consider using --exclude to avoid checking one of them.
129129
== Return code: 2
130130

@@ -1140,7 +1140,7 @@ import foo.bar
11401140
[file src/foo/bar.py]
11411141
1+'x'
11421142
[out]
1143-
src/foo/bar.py: error: Source file found twice under different module names: 'src.foo.bar' and 'foo.bar'
1143+
src/foo/bar.py: error: Source file found twice under different module names: "src.foo.bar" and "foo.bar"
11441144
== Return code: 2
11451145

11461146
[case testEnableInvalidErrorCode]

0 commit comments

Comments
 (0)