Skip to content

Commit 8acfc9d

Browse files
author
Guido van Rossum
committed
Add test showing that generics work (this was previously broken)
1 parent 24fd09a commit 8acfc9d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

test-data/unit/check-classes.test

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3194,6 +3194,23 @@ C2().foo()
31943194
C2().bar()
31953195
C2().baz() # E: "C2" has no attribute "baz"
31963196

3197+
[case testSixWithMetaclassGenerics]
3198+
from typing import Generic, GenericMeta, TypeVar
3199+
import six
3200+
class DestroyableMeta(type):
3201+
pass
3202+
class Destroyable(six.with_metaclass(DestroyableMeta)):
3203+
pass
3204+
T_co = TypeVar('T_co', bound='Destroyable', covariant=True)
3205+
class ArcMeta(GenericMeta, DestroyableMeta):
3206+
pass
3207+
class Arc(six.with_metaclass(ArcMeta, Generic[T_co], Destroyable)):
3208+
pass
3209+
class MyDestr(Destroyable):
3210+
pass
3211+
reveal_type(Arc[MyDestr]()) # E: Revealed type is '__main__.Arc[__main__.MyDestr*]'
3212+
[builtins fixtures/bool.pyi]
3213+
31973214
[case testSixWithMetaclassErrors]
31983215
import six
31993216
class M(type): pass

test-data/unit/lib-stub/typing.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
from abc import abstractmethod
55

6+
class GenericMeta(type): pass
7+
68
cast = 0
79
overload = 0
810
Any = 0

0 commit comments

Comments
 (0)