@@ -3525,27 +3525,31 @@ class M(type):
3525
3525
x = 5
3526
3526
3527
3527
[case testSixMetaclassAndBase]
3528
+ from typing import Iterable, Iterator
3528
3529
import six
3529
- class M(type):
3530
+ class M(type, Iterable[int] ):
3530
3531
x = 5
3532
+ def __iter__(self) -> Iterator[int]: ...
3531
3533
class A:
3532
3534
def foo(self): pass
3533
3535
class B:
3534
3536
def bar(self): pass
3535
3537
class C1(six.with_metaclass(M, A)): pass
3536
- class C2(six.with_metaclass(M, A, B)): pass
3537
3538
@six.add_metaclass(M)
3538
3539
class D1(A): pass
3540
+ class C2(six.with_metaclass(M, A, B)): pass
3539
3541
@six.add_metaclass(M)
3540
3542
class D2(A, B): pass
3541
3543
reveal_type(type(C1).x) # E: Revealed type is 'builtins.int'
3542
- reveal_type(type(C2).x) # E: Revealed type is 'builtins.int'
3543
3544
reveal_type(type(D1).x) # E: Revealed type is 'builtins.int'
3545
+ reveal_type(type(C2).x) # E: Revealed type is 'builtins.int'
3544
3546
reveal_type(type(D2).x) # E: Revealed type is 'builtins.int'
3545
3547
C1().foo()
3546
3548
D1().foo()
3547
3549
C1().bar() # E: "C1" has no attribute "bar"
3548
3550
D1().bar() # E: "D1" has no attribute "bar"
3551
+ for x in C1: reveal_type(x) # E: Revealed type is 'builtins.int*'
3552
+ for x in C2: reveal_type(x) # E: Revealed type is 'builtins.int*'
3549
3553
C2().foo()
3550
3554
D2().foo()
3551
3555
C2().bar()
@@ -3591,6 +3595,21 @@ class C5(six.with_metaclass(f())): pass # E: Dynamic metaclass not supported fo
3591
3595
@six.add_metaclass(f()) # E: Dynamic metaclass not supported for 'D5'
3592
3596
class D5: pass
3593
3597
3598
+ @six.add_metaclass(M) # E: Multiple metaclass definitions
3599
+ class CD(six.with_metaclass(M)): pass
3600
+
3601
+ def q(t):
3602
+ class E(metaclass=t): pass
3603
+ class F(six.with_metaclass(t)): pass
3604
+ @six.add_metaclass(t)
3605
+ class G: pass
3606
+
3607
+ class M1(type): pass
3608
+ class Q1(metaclass=M1): pass
3609
+ @six.add_metaclass(M) # E: Inconsistent metaclass structure for 'CQA'
3610
+ class CQA(Q1): pass
3611
+ class CQW(six.with_metaclass(M, Q1)): pass # E: Inconsistent metaclass structure for 'CQW'
3612
+
3594
3613
[case testSixMetaclassErrors_python2]
3595
3614
# flags: --python-version 2.7
3596
3615
import six
0 commit comments