You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test-data/unit/check-classes.test
+37-4Lines changed: 37 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -4351,7 +4351,7 @@ class C(B):
4351
4351
class X(type): pass
4352
4352
class Y(type): pass
4353
4353
class A(metaclass=X): pass
4354
-
class B(A, metaclass=Y): pass # E: Inconsistent metaclass structure for "B"
4354
+
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
class CQA(Q1): pass # E: Inconsistent metaclass structure for "CQA"
5217
-
class CQW(six.with_metaclass(M, Q1)): pass # E: Inconsistent metaclass structure for "CQW"
5216
+
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
5217
+
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
5218
5218
[builtins fixtures/tuple.pyi]
5219
5219
5220
5220
[case testSixMetaclassAny]
@@ -5319,7 +5319,7 @@ class C5(future.utils.with_metaclass(f())): pass # E: Dynamic metaclass not sup
5319
5319
5320
5320
class M1(type): pass
5321
5321
class Q1(metaclass=M1): pass
5322
-
class CQW(future.utils.with_metaclass(M, Q1)): pass # E: Inconsistent metaclass structure for "CQW"
5322
+
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
5323
5323
[builtins fixtures/tuple.pyi]
5324
5324
5325
5325
[case testFutureMetaclassAny]
@@ -6718,6 +6718,39 @@ class Meta(A): pass
6718
6718
from m import Meta
6719
6719
class A(metaclass=Meta): pass
6720
6720
6721
+
[case testMetaclassConflict]
6722
+
class MyMeta1(type): ...
6723
+
class MyMeta2(type): ...
6724
+
class MyMeta3(type): ...
6725
+
class A(metaclass=MyMeta1): ...
6726
+
class B(metaclass=MyMeta2): ...
6727
+
class C(metaclass=type): ...
6728
+
class A1(A): ...
6729
+
class E: ...
6730
+
6731
+
class CorrectMeta(MyMeta1, MyMeta2): ...
6732
+
class CorrectSubclass1(A1, B, E, metaclass=CorrectMeta): ...
6733
+
class CorrectSubclass2(A, B, E, metaclass=CorrectMeta): ...
6734
+
class CorrectSubclass3(B, A, metaclass=CorrectMeta): ...
6735
+
6736
+
class ChildOfCorrectSubclass1(CorrectSubclass1): ...
6737
+
6738
+
class CorrectWithType1(C, A1): ...
6739
+
class CorrectWithType2(B, C): ...
6740
+
6741
+
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
6742
+
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
6743
+
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
6744
+
6745
+
class ChildOfConflict1(Conflict3): ... # E: Metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
6746
+
class ChildOfConflict2(Conflict3, metaclass=CorrectMeta): ...
6747
+
6748
+
class ConflictingMeta(MyMeta1, MyMeta3): ...
6749
+
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
6750
+
6751
+
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
0 commit comments