File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -3157,3 +3157,37 @@ class M(type):
3157
3157
x = 5
3158
3158
class A(with_metaclass(M)): pass
3159
3159
reveal_type(type(A).x) # E: Revealed type is 'builtins.int'
3160
+
3161
+ [case testSixWithMetaclassAndBase]
3162
+ import six
3163
+ class M(type):
3164
+ x = 5
3165
+ class A:
3166
+ def foo(self): pass
3167
+ class B:
3168
+ def bar(self): pass
3169
+ class C1(six.with_metaclass(M, A)): pass
3170
+ class C2(six.with_metaclass(M, A, B)): pass
3171
+ reveal_type(type(C1).x) # E: Revealed type is 'builtins.int'
3172
+ reveal_type(type(C2).x) # E: Revealed type is 'builtins.int'
3173
+ C1().foo()
3174
+ C1().bar() # E: "C1" has no attribute "bar"
3175
+ C2().foo()
3176
+ C2().bar()
3177
+ C2().baz() # E: "C2" has no attribute "baz"
3178
+
3179
+ [case testSixWithMetaclassErrors]
3180
+ import six
3181
+ class M(type): pass
3182
+ class A(object): pass
3183
+ class C1(six.with_metaclass(M), object): pass # E: Invalid base class
3184
+ class C2(C1, six.with_metaclass(M)): pass # E: Invalid base class
3185
+ class C3(six.with_metaclass(A)): pass # E: Metaclasses not inheriting from 'type' are not supported
3186
+ class C4(six.with_metaclass(M), metaclass=M): pass # E: Invalid base class
3187
+
3188
+ [case testSixWithMetaclassErrors_python2-skip]
3189
+ # No error here yet
3190
+ import six
3191
+ class M(type): pass
3192
+ class C4(six.with_metaclass(M)):
3193
+ __metaclass__ = M
You can’t perform that action at this time.
0 commit comments