Skip to content

Commit d5eb32d

Browse files
ilinummatthiaskramm
authored andcommitted
Support iteration over enums with enum34 (#1412)
* Support iteration over enums in python 2 * fix lint
1 parent a8dea5e commit d5eb32d

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

third_party/2/enum.pyi

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
from typing import List, Any, TypeVar, Type
1+
from typing import List, Any, TypeVar, Type, Iterable, Iterator
22

3-
class Enum:
4-
def __new__(cls, value: Any) -> None: ...
3+
_T = TypeVar('_T', bound=Enum)
4+
class EnumMeta(type, Iterable[Enum]):
5+
def __iter__(self: Type[_T]) -> Iterator[_T]: ... # type: ignore
6+
7+
class Enum(metaclass=EnumMeta):
8+
def __new__(cls: Type[_T], value: Any) -> _T: ...
59
def __repr__(self) -> str: ...
610
def __str__(self) -> str: ...
711
def __dir__(self) -> List[str]: ...
@@ -12,8 +16,6 @@ class Enum:
1216
name = ... # type: str
1317
value = ... # type: Any
1418

15-
_T = TypeVar('_T')
16-
1719
class IntEnum(int, Enum): # type: ignore
1820
def __new__(cls: Type[_T], value: Any) -> _T: ...
1921

0 commit comments

Comments
 (0)