Support enum iteration (#1136)

* Support enum iteration.

Fixes python/mypy#2305.

* Make EnumMeta inherit from type, not ABCMeta.
This commit is contained in:
Guido van Rossum
2017-04-04 10:17:52 -07:00
committed by Jelle Zijlstra
parent 56e7aa6b48
commit 7027c3e4e8

View File

@@ -1,12 +1,13 @@
# FIXME: Stub incomplete, ommissions include:
# * the metaclass
# * _sunder_ methods with their transformations
import sys
from typing import List, Any, TypeVar, Union
from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type
class Enum:
def __new__(cls, value: Any) -> None: ...
_T = TypeVar('_T', bound=Enum)
class EnumMeta(type, Iterable[Enum]):
def __iter__(self: Type[_T]) -> Iterator[_T]: ... # type: ignore
class Enum(metaclass=EnumMeta):
def __new__(cls: Type[_T], value: Any) -> _T: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def __dir__(self) -> List[str]: ...
@@ -20,8 +21,6 @@ class Enum:
class IntEnum(int, Enum):
value = ... # type: int
_T = TypeVar('_T')
def unique(enumeration: _T) -> _T: ...
if sys.version_info >= (3, 6):