Skip to content

Commit bebb49a

Browse files
author
Guido van Rossum
committed
Support enum iteration.
Fixes python/mypy#2305.
1 parent f192b8c commit bebb49a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

stdlib/3.4/enum.pyi

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
# FIXME: Stub incomplete, ommissions include:
2-
# * the metaclass
32
# * _sunder_ methods with their transformations
43

4+
import abc
55
import sys
6-
from typing import List, Any, TypeVar, Union
6+
from typing import List, Any, TypeVar, Union, Iterable, Iterator, TypeVar, Generic, Type
77

8-
class Enum:
9-
def __new__(cls, value: Any) -> None: ...
8+
_T = TypeVar('_T', bound=Enum)
9+
10+
class EnumMeta(abc.ABCMeta, Iterable[Enum]):
11+
def __iter__(self: Type[_T]) -> Iterator[_T]: ... # type: ignore
12+
13+
class Enum(metaclass=EnumMeta):
14+
def __new__(cls: Type[_T], value: Any) -> _T: ...
1015
def __repr__(self) -> str: ...
1116
def __str__(self) -> str: ...
1217
def __dir__(self) -> List[str]: ...
@@ -20,8 +25,6 @@ class Enum:
2025
class IntEnum(int, Enum):
2126
value = ... # type: int
2227

23-
_T = TypeVar('_T')
24-
2528
def unique(enumeration: _T) -> _T: ...
2629

2730
if sys.version_info >= (3, 6):

0 commit comments

Comments
 (0)