From 38eee3fd796e26a8ced2e5253820720d44d18485 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Wed, 18 May 2016 16:54:27 -0700 Subject: [PATCH 1/3] Add stub version of Type[C]. --- stdlib/2.7/typing.pyi | 4 ++++ stdlib/3/typing.pyi | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/stdlib/2.7/typing.pyi b/stdlib/2.7/typing.pyi index 461a6e76efeb..be3bb4275aac 100644 --- a/stdlib/2.7/typing.pyi +++ b/stdlib/2.7/typing.pyi @@ -184,6 +184,10 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): @overload def update(self, m: Iterable[Tuple[_KT, _VT]]) -> None: ... +CT = TypeVar('CT', bound=type) +class Type(type, Generic[CT]): + pass + Text = unicode class IO(Iterable[AnyStr], Generic[AnyStr]): diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index 2bbb8bbea2c3..eef9048bc8d8 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -251,6 +251,10 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): @overload def update(self, m: Iterable[Tuple[_KT, _VT]]) -> None: ... +CT = TypeVar('CT', bound=type) +class Type(type, Generic[CT]): + pass + Text = str class IO(Iterable[AnyStr], Generic[AnyStr]): From 99e1083564d1907790f7a6c9b3ba1bc43ca05edd Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 19 May 2016 14:55:34 -0700 Subject: [PATCH 2/3] Make CT covariant. --- stdlib/2.7/typing.pyi | 2 +- stdlib/3/typing.pyi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/2.7/typing.pyi b/stdlib/2.7/typing.pyi index be3bb4275aac..4097fcfbc2fa 100644 --- a/stdlib/2.7/typing.pyi +++ b/stdlib/2.7/typing.pyi @@ -184,7 +184,7 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): @overload def update(self, m: Iterable[Tuple[_KT, _VT]]) -> None: ... -CT = TypeVar('CT', bound=type) +CT = TypeVar('CT', covariant=True, bound=type) class Type(type, Generic[CT]): pass diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index eef9048bc8d8..a9936b495cd7 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -251,7 +251,7 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): @overload def update(self, m: Iterable[Tuple[_KT, _VT]]) -> None: ... -CT = TypeVar('CT', bound=type) +CT = TypeVar('CT', covariant=True, bound=type) class Type(type, Generic[CT]): pass From 64e9a0f0fc92a15e35d9abaf2b636299d1b343ef Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 20 May 2016 11:15:20 -0700 Subject: [PATCH 3/3] Different approach to defining Type in typing.pyi. --- stdlib/2.7/typing.pyi | 5 +---- stdlib/3/typing.pyi | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/stdlib/2.7/typing.pyi b/stdlib/2.7/typing.pyi index 4097fcfbc2fa..9d7446909f95 100644 --- a/stdlib/2.7/typing.pyi +++ b/stdlib/2.7/typing.pyi @@ -12,6 +12,7 @@ TypeVar = object() Generic = object() Tuple = object() Callable = object() +Type = object() builtinclass = object() _promote = object() NamedTuple = object() @@ -184,10 +185,6 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): @overload def update(self, m: Iterable[Tuple[_KT, _VT]]) -> None: ... -CT = TypeVar('CT', covariant=True, bound=type) -class Type(type, Generic[CT]): - pass - Text = unicode class IO(Iterable[AnyStr], Generic[AnyStr]): diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index a9936b495cd7..33235c799487 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -12,6 +12,7 @@ TypeVar = object() Generic = object() Tuple = object() Callable = object() +Type = object() builtinclass = object() _promote = object() NamedTuple = object() @@ -251,10 +252,6 @@ class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): @overload def update(self, m: Iterable[Tuple[_KT, _VT]]) -> None: ... -CT = TypeVar('CT', covariant=True, bound=type) -class Type(type, Generic[CT]): - pass - Text = str class IO(Iterable[AnyStr], Generic[AnyStr]):