From 0a787866b6132aaf86e4019794b3430dd3035f0e Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 4 Apr 2017 13:57:42 -0700 Subject: [PATCH 1/2] Use a separate type variable for unique() See https://github.com/python/typeshed/pull/1136#discussion_r109727053 --- stdlib/3.4/enum.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/stdlib/3.4/enum.pyi b/stdlib/3.4/enum.pyi index 4f27d33f2f08..2789011843e4 100644 --- a/stdlib/3.4/enum.pyi +++ b/stdlib/3.4/enum.pyi @@ -2,6 +2,7 @@ import sys from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type _T = TypeVar('_T', bound=Enum) +_S = TypeVar('_S', bound=Type[Enum]) class EnumMeta(type, Iterable[Enum]): def __iter__(self: Type[_T]) -> Iterator[_T]: ... # type: ignore From 16cac8ba1dacb3b44c518c1a32d72c9a6efbb27a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 4 Apr 2017 23:32:41 -0700 Subject: [PATCH 2/2] actually use the new typevar --- stdlib/3.4/enum.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/3.4/enum.pyi b/stdlib/3.4/enum.pyi index 2789011843e4..96a3a0a18ac4 100644 --- a/stdlib/3.4/enum.pyi +++ b/stdlib/3.4/enum.pyi @@ -22,7 +22,7 @@ class Enum(metaclass=EnumMeta): class IntEnum(int, Enum): value = ... # type: int -def unique(enumeration: _T) -> _T: ... +def unique(enumeration: _S) -> _S: ... if sys.version_info >= (3, 6): _auto_null = ... # type: Any