Skip to content

Commit 4aed608

Browse files
committed
consistent quoting
1 parent 570b9f6 commit 4aed608

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

mypy/nodes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,27 +3414,27 @@ def explain_metaclass_conflict(self) -> str | None:
34143414
if declared is None:
34153415
resolution_steps = []
34163416
else:
3417-
resolution_steps = [f"{declared.type.fullname} (meta of {self.fullname})"]
3417+
resolution_steps = [f'"{declared.type.fullname}" (metaclass of "{self.fullname}")']
34183418
for super_class in self.mro[1:]:
34193419
super_meta = super_class.declared_metaclass
34203420
if super_meta is None or super_meta.type is None:
34213421
continue
34223422
if winner is None:
34233423
winner = super_meta
34243424
resolution_steps.append(
3425-
f"{winner.type.fullname} (metaclass of {super_class.fullname})"
3425+
f'"{winner.type.fullname}" (metaclass of "{super_class.fullname}")'
34263426
)
34273427
continue
34283428
if winner.type.has_base(super_meta.type.fullname):
34293429
continue
34303430
if super_meta.type.has_base(winner.type.fullname):
34313431
winner = super_meta
34323432
resolution_steps.append(
3433-
f"{winner.type.fullname} (metaclass of {super_class.fullname})"
3433+
f'"{winner.type.fullname}" (metaclass of "{super_class.fullname}")'
34343434
)
34353435
continue
34363436
# metaclass conflict
3437-
conflict = f"{super_meta.type.fullname} (metaclass of {super_class.fullname})"
3437+
conflict = f'"{super_meta.type.fullname}" (metaclass of "{super_class.fullname}")'
34383438
return f"{' > '.join(resolution_steps)} conflicts with {conflict}"
34393439

34403440
return None

test-data/unit/check-classes.test

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4758,9 +4758,7 @@ class X(type): pass
47584758
class Y(type): pass
47594759
class A(metaclass=X): pass
47604760
class B(A, metaclass=Y): pass # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases \
4761-
# N: __main__.Y (meta of __main__.B) conflicts with __main__.X (metaclass of __main__.A)
4762-
4763-
4761+
# N: "__main__.Y" (metaclass of "__main__.B") conflicts with "__main__.X" (metaclass of "__main__.A")
47644762
[case testMetaclassNoTypeReveal]
47654763
class M:
47664764
x = 0 # type: int
@@ -5757,10 +5755,9 @@ class M1(type): pass
57575755
class Q1(metaclass=M1): pass
57585756
@six.add_metaclass(M)
57595757
class CQA(Q1): pass # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases \
5760-
# N: __main__.M (meta of __main__.CQA) conflicts with __main__.M1 (metaclass of __main__.Q1)
5758+
# N: "__main__.M" (metaclass of "__main__.CQA") conflicts with "__main__.M1" (metaclass of "__main__.Q1")
57615759
class CQW(six.with_metaclass(M, Q1)): pass # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases \
5762-
# N: __main__.M (meta of __main__.CQW) conflicts with __main__.M1 (metaclass of __main__.Q1)
5763-
5760+
# N: "__main__.M" (metaclass of "__main__.CQW") conflicts with "__main__.M1" (metaclass of "__main__.Q1")
57645761
[builtins fixtures/tuple.pyi]
57655762

57665763
[case testSixMetaclassAny]
@@ -5879,8 +5876,7 @@ class C5(future.utils.with_metaclass(f())): pass # E: Dynamic metaclass not sup
58795876
class M1(type): pass
58805877
class Q1(metaclass=M1): pass
58815878
class CQW(future.utils.with_metaclass(M, Q1)): pass # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases \
5882-
# N: __main__.M (meta of __main__.CQW) conflicts with __main__.M1 (metaclass of __main__.Q1)
5883-
5879+
# N: "__main__.M" (metaclass of "__main__.CQW") conflicts with "__main__.M1" (metaclass of "__main__.Q1")
58845880
[builtins fixtures/tuple.pyi]
58855881

58865882
[case testFutureMetaclassAny]
@@ -7350,21 +7346,21 @@ class CorrectWithType1(C, A1): ...
73507346
class CorrectWithType2(B, C): ...
73517347

73527348
class Conflict1(A1, B, E): ... # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases \
7353-
# N: __main__.MyMeta1 (metaclass of __main__.A) conflicts with __main__.MyMeta2 (metaclass of __main__.B)
7349+
# N: "__main__.MyMeta1" (metaclass of "__main__.A") conflicts with "__main__.MyMeta2" (metaclass of "__main__.B")
73547350
class Conflict2(A, B): ... # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases \
7355-
# N: __main__.MyMeta1 (metaclass of __main__.A) conflicts with __main__.MyMeta2 (metaclass of __main__.B)
7351+
# N: "__main__.MyMeta1" (metaclass of "__main__.A") conflicts with "__main__.MyMeta2" (metaclass of "__main__.B")
73567352
class Conflict3(B, A): ... # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases \
7357-
# N: __main__.MyMeta2 (metaclass of __main__.B) conflicts with __main__.MyMeta1 (metaclass of __main__.A)
7353+
# N: "__main__.MyMeta2" (metaclass of "__main__.B") conflicts with "__main__.MyMeta1" (metaclass of "__main__.A")
73587354

73597355
class ChildOfConflict1(Conflict3): ...
73607356
class ChildOfConflict2(Conflict3, metaclass=CorrectMeta): ...
73617357

73627358
class ConflictingMeta(MyMeta1, MyMeta3): ...
73637359
class Conflict4(A1, B, E, metaclass=ConflictingMeta): ... # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases \
7364-
# N: __main__.ConflictingMeta (meta of __main__.Conflict4) conflicts with __main__.MyMeta2 (metaclass of __main__.B)
7360+
# N: "__main__.ConflictingMeta" (metaclass of "__main__.Conflict4") conflicts with "__main__.MyMeta2" (metaclass of "__main__.B")
73657361

73667362
class ChildOfCorrectButWrongMeta(CorrectSubclass1, metaclass=ConflictingMeta): # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases \
7367-
# N: __main__.ConflictingMeta (meta of __main__.ChildOfCorrectButWrongMeta) conflicts with __main__.CorrectMeta (metaclass of __main__.CorrectSubclass1)
7363+
# N: "__main__.ConflictingMeta" (metaclass of "__main__.ChildOfCorrectButWrongMeta") conflicts with "__main__.CorrectMeta" (metaclass of "__main__.CorrectSubclass1")
73687364
...
73697365

73707366
[case testMetaClassConflictIssue14033]
@@ -7380,9 +7376,9 @@ class B1(metaclass=M2): pass
73807376
class C1(metaclass=Mx): pass
73817377

73827378
class TestABC(A2, B1, C1): pass # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases \
7383-
# N: __main__.M1 (metaclass of __main__.A1) conflicts with __main__.M2 (metaclass of __main__.B1)
7379+
# N: "__main__.M1" (metaclass of "__main__.A1") conflicts with "__main__.M2" (metaclass of "__main__.B1")
73847380
class TestBAC(B1, A2, C1): pass # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases \
7385-
# N: __main__.M2 (metaclass of __main__.B1) conflicts with __main__.M1 (metaclass of __main__.A1)
7381+
# N: "__main__.M2" (metaclass of "__main__.B1") conflicts with "__main__.M1" (metaclass of "__main__.A1")
73867382

73877383
# should not warn again for children
73887384
class ChildOfTestABC(TestABC): pass

test-data/unit/check-errorcodes.test

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,9 @@ class X(type): pass
12761276
class Y(type): pass
12771277
class A(metaclass=X): pass
12781278
class B(A, metaclass=Y): pass # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases [metaclass] \
1279-
# N: __main__.Y (meta of __main__.B) conflicts with __main__.X (metaclass of __main__.A)
1279+
# N: "__main__.Y" (metaclass of "__main__.B") conflicts with "__main__.X" (metaclass of "__main__.A")
1280+
1281+
12801282

12811283

12821284
[case testOverloadedFunctionSignature]

test-data/unit/fine-grained.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2955,7 +2955,7 @@ class M(type): pass
29552955
[out]
29562956
==
29572957
a.py:3: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
2958-
a.py:3: note: a.M2 (meta of a.D) conflicts with c.M (metaclass of b.B)
2958+
a.py:3: note: "a.M2" (metaclass of "a.D") conflicts with "c.M" (metaclass of "b.B")
29592959

29602960
[case testFineMetaclassDeclaredUpdate]
29612961
import a
@@ -2975,7 +2975,7 @@ class M2(type): pass
29752975
[out]
29762976
==
29772977
a.py:3: error: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
2978-
a.py:3: note: b.M2 (meta of a.D) conflicts with b.M (metaclass of a.B)
2978+
a.py:3: note: "b.M2" (metaclass of "a.D") conflicts with "b.M" (metaclass of "a.B")
29792979

29802980
[case testFineMetaclassRemoveFromClass]
29812981
import a

0 commit comments

Comments
 (0)